Discussion:
Suggestions for Encryption Algorithms and Languages?? [ I'm new at this ]
(too old to reply)
Robert Blass
2008-09-17 17:22:10 UTC
Permalink
I am looking to get my feet wet with encryption. When I say encryption
program I am talking about something to get me off to a quick start.
Something very simple, far less than the 40+ bit encryption code.

What I need is an easy to understand language choice. I've used BASIC
a long time ago but is there another language that is better and more
supported?

There seems to be hundreds of languages so it's hard for me to just
pick one.

I also wanted it to be a freeware or shareware programming language
with a compiler and maybe an editor that has colors and error
checking. I'll need it to be usable in a windows/xp environment.
Maybe a one that compiles into a self supportive EXE?

As I said I am just starting by trying to code a very simple
encryption program. If anything fits this bell then please give me
some information.

Thanks.

Message was cross-posted to the following Newsgroups in hopes of
getting more replies.
comp.lang.basic.powerbasic,comp.lang.misc,comp.lang.java,comp.lang.c++,comp.lang.c,comp.lang.c.moderated
Auric__
2008-09-17 21:18:43 UTC
Permalink
Post by Robert Blass
I am looking to get my feet wet with encryption. When I say encryption
program I am talking about something to get me off to a quick start.
Something very simple, far less than the 40+ bit encryption code.
*Very* simple? Start with ROT-13.
Post by Robert Blass
What I need is an easy to understand language choice. I've used BASIC
a long time ago but is there another language that is better and more
supported?
Basic *is* well-supported.
Post by Robert Blass
There seems to be hundreds of languages so it's hard for me to just
pick one.
So stick with what you know.
Post by Robert Blass
I also wanted it to be a freeware or shareware programming language
with a compiler and maybe an editor that has colors and error
checking. I'll need it to be usable in a windows/xp environment.
Maybe a one that compiles into a self supportive EXE?
FreeBASIC:
http://www.freebasic.net/
Post by Robert Blass
As I said I am just starting by trying to code a very simple
encryption program. If anything fits this bell then please give me
some information.
Try reading the wikipedia page on encryption. That should be a good
starting place.
Post by Robert Blass
Message was cross-posted to the following Newsgroups in hopes of
getting more replies.
comp.lang.basic.powerbasic,comp.lang.misc,comp.lang.java,comp.lang.c++,co
mp.lang.c,comp.lang.c.moderated
That's not a cross-post, that's a multi-post, usually considered a Bad
Thing. Cross-posting involves typing all of those into the "Newsgroups"
line *at the same time*.
--
Did atheists first come from Athens?
m***@privacy.net
2008-09-19 22:52:48 UTC
Permalink
Message was [...] posted to the following Newsgroups in hopes of
getting more replies.
comp.lang.basic.powerbasic,comp.lang.misc,comp.lang.java,comp.lang.c++,comp.lang.c,comp.lang.c.moderated
Answer was not posted because you posted to the following Newsgroups.
comp.lang.basic.powerbasic,comp.lang.misc,comp.lang.java,comp.lang.c++,comp.lang.c,comp.lang.c.moderated

Don't do that. It puts your needs above the convenience of the reader.
Olav
2008-10-27 22:48:44 UTC
Permalink
Post by Robert Blass
I am looking to get my feet wet with encryption. When I say encryption
program I am talking about something to get me off to a quick start.
Something very simple, far less than the 40+ bit encryption code.
What I need is an easy to understand language choice. I've used BASIC
a long time ago but is there another language that is better and more
supported?
There seems to be hundreds of languages so it's hard for me to just
pick one.
I also wanted it to be a freeware or shareware programming language
with a compiler and maybe an editor that has colors and error
checking. I'll need it to be usable in a windows/xp environment.
Maybe a one that compiles into a self supportive EXE?
As I said I am just starting by trying to code a very simple
encryption program. If anything fits this bell then please give me
some information.
Thanks.
Message was cross-posted to the following Newsgroups in hopes of
getting more replies.
comp.lang.basic.powerbasic,comp.lang.misc,comp.lang.java,comp.lang.c++,comp.lang.c,comp.lang.c.moderated
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Maybe you could make use of Capicom[.dll].See
http://msdn.microsoft.com/en-us/library/aa388154(VS.85).aspx
Below is a simple demo showing how Capicom can be used to encrypt a
string/file.

rem %Debug=1
rem #INCLUDE "Debug.inc"
#COMPILE EXE "C:\Test"
#COMPILER PBCC 4.04
#DIM ALL
#INCLUDE "Win32API.INC"
'-----------------------------------------------------------------------------------------------------------------------------
%CAPICOM_ENCRYPTION_ALGORITHM_AES = &H00000004 'Produced by
PBrow.exe
%CAPICOM_ENCRYPTION_KEY_LENGTH_MAXIMUM = &H00000000
%CAPICOM_SECRET_PASSWORD = &H00000000
%CAPICOM_ENCODE_BASE64 = &H00000000
'-------------------------------------------------------------------------------------------------------------------------------
SUB Encrypt(File AS STRING,Secret AS VARIANT)

LOCAL hFile AS LONG
LOCAL buf,KyLength, AlgoName,cipherText,vVnt,Buf2,vntSecret,EncodingType
AS VARIANT
LOCAL Buff AS STRING

DIM oCapiCom AS LOCAL DISPATCH 'Late binding
'DIM oCapiCom AS LOCAL CAPICOMEncryptedData 'Early Binding
DIM A AS LOCAL ASCIIZ * 1024

TRY
'CALL CoInitialize(BYVAL %NULL)' not necessary in a single-threaded exe
'SET oCapiCom = NEW CAPICOMEncryptedData IN "CAPICOM.EncryptedData.1"
'early binding.Faster
SET oCapiCom = NEW DISPATCH IN "CAPICOM.EncryptedData.1" 'Late binding
IF ISFALSE ISOBJECT(oCapiCom) THEN ERROR 151 'Would like to be able to
assign an descriptive error text to user customized errors

hFile = FREEFILE
OPEN File FOR BINARY AS #hFile
GET$ #hFile,LOF(hFile),Buff
LET Buf = Buff
CLOSE #hFile

OBJECT LET oCapiCom.Content = Buf
OBJECT GET oCapiCom.Algorithm TO vVnt

AlgoName = %CAPICOM_ENCRYPTION_ALGORITHM_AES
OBJECT LET oCapiCom.Algorithm.Name = AlgoName

KyLength = %CAPICOM_ENCRYPTION_KEY_LENGTH_MAXIMUM
OBJECT LET oCapiCom.Algorithm.KeyLength() = KyLength

vntSecret = %CAPICOM_SECRET_PASSWORD
OBJECT CALL oCapiCom.SetSecret(Secret,vntSecret)

EncodingType = %CAPICOM_ENCODE_BASE64
OBJECT CALL oCapiCom.Encrypt(EncodingType) TO cipherText

hFile = FREEFILE
OPEN File + ".encrypted" FOR OUTPUT AS #hFile
PRINT #hFile,VARIANT$(cipherText)
? VARIANT$(cipherText)
CLOSE #hFile

CATCH
CLOSE #hFile
SELECT CASE ERR
CASE 151
? "Error" + STR$(ERRCLEAR) + ":Invalid object"
CASE ELSE
IF ISTRUE OBJRESULT THEN
CALL FormatMessage(%FORMAT_MESSAGE_FROM_SYSTEM,BYVAL
0&,OBJRESULT,_
BYVAL
MAKELANGID(%LANG_NEUTRAL,%SUBLANG_DEFAULT),_
A,SIZEOF(A),BYVAL 0&)
ELSE
? "Error" + STR$(ERR) + ERROR$(ERRCLEAR)
END IF
END SELECT
END TRY

SET oCapiCom = NOTHING
'CALL CoUninitialize '

END SUB
'-------------------------------------------------------------------------------------------------------------------------------
SUB Decrypt(File AS STRING,Secret AS VARIANT)
LOCAL hFile,lSize AS LONG
LOCAL vntSecret,plainText,buf AS VARIANT
LOCAL sName,buff AS STRING

'DIM oCapiCom AS LOCAL CAPICOMEncryptedData 'Early Binding
DIM oCapiCom AS LOCAL DISPATCH 'Late Binding
DIM A AS LOCAL ASCIIZ * 1024

TRY
'SET oCapiCom = NEW CAPICOMEncryptedData IN "CAPICOM.EncryptedData.1"
'early binding
SET oCapiCom = NEW DISPATCH IN "CAPICOM.EncryptedData.1" 'late binding
'SET oCapiCom = NEW dispatch IN "CAPICOM.EncryptedData.1" 'Late binding
IF ISFALSE ISOBJECT(oCapiCom)THEN ERROR 151

hFile = FREEFILE
OPEN File + ".encrypted" FOR BINARY AS #hFile
GET$ #hFile,LOF(hFile),buff
LET buf = buff
CLOSE #hFile

vntSecret = %CAPICOM_SECRET_PASSWORD
OBJECT CALL oCapicom.SetSecret(Secret,vntSecret)
OBJECT CALL oCapicom.Decrypt(buf)
OBJECT GET oCapicom.Content TO plainText

hFile = FREEFILE
OPEN File + ".decrypted" FOR BINARY AS #hFile
buff = VARIANT$(plaintext)
PUT$ #hFile,buff
? Buff
CLOSE #hFile
CATCH
CLOSE #hFile
SELECT CASE ERR
CASE 151
? "Error" + STR$(ERRCLEAR) + ".Invalid object"
CASE ELSE
IF ISTRUE OBJRESULT THEN
CALL FormatMessage(%FORMAT_MESSAGE_FROM_SYSTEM,BYVAL
0&,OBJRESULT,_
BYVAL
MAKELANGID(%LANG_NEUTRAL,%SUBLANG_DEFAULT),_
A,SIZEOF(A),BYVAL 0&)
ELSE
? "Error:" + ERROR$(ERRCLEAR)
END IF
END SELECT
END TRY
SET oCapiCom = NOTHING
END SUB
'-------------------------------------------------------------------------------------------------------------------------------
FUNCTION PBMAIN () AS LONG
LOCAL sSecret AS VARIANT

sSecret = "EnterYourPasswordHere"
CALL Encrypt(".\Test.txt",sSecret) 'change file name to something that
suits your needs.
CALL Decrypt(".\Test.txt",sSecret)
?
SHELL "FC .\Test.txt .\Test.txt.decrypted" 'Compare original text with
decrypted text
?
? "Press a key to end the program..."
WAITKEY$
END FUNCTION

--
Olav

Continue reading on narkive:
Loading...