Tips   >   Externals   >   Blowfish Object
The blowfish external can be use to encrypt/decrypt passwords.
It is best to store all passwords in an encrypted form so that nobody, not even the system administrator, can see actual passwords. If a user forgets their password it is better practice to reset the password, than to view their existing password.
To use the blowfish external you need to instantiate it with an object type variable.
Calculate cInitialKey as 'mykey'
Do oBlowfish.$initkey(cInitialKey)
Prompt for input Enter a password to encrypt Returns MyPassword
Do oBlowfish.$encrypt(MyPassword) Returns cBinaryVariable
OK message (Icon) {Your password has been encrypted to a binary value using the key '[cInitialKey]'////The 'Decrypt a String' demo will decrypt the string.}
Do oBlowfish.$initkey(cInitialKey)
Do oBlowfish.$decrypt(cBinaryVariable) Returns DecryptedString
OK message (Icon) {The decrypted password is: '[DecryptedString]'}
I am a newbie to encryption so the following comments are just some of my initial thoughts on implementing blowfish.
Where do we store the key?
Calculate cInitialKey as 'mykey'
Prompt for input Enter a password to encrypt Returns MyPassword
Do oBlowfish.$initkey(MyPassword)
Do oBlowfish.$encrypt(MyPassword) Returns cBinaryVariable
OK message (Icon) {Your password has been encrypted to a binary value.}
Prompt for input Enter your password Returns RenterPassword
Do oBlowfish.$initkey(RenterPassword)
Do oBlowfish.$decrypt(cBinaryVariable) Returns DecryptedString
OK message (Icon) {The decrypted password is: '[DecryptedString]'}
The Omnis Studio
discusses an optional header parameter as follows:The bIncludeHeader parameter is a boolean to indicate whether or not a header should be appended to the data. The encrypted data is always the same length as the decrypted data except for an additional 8 byte header (if required).
I tested encrypting a message with bIncludeHeader set to true, and then decrypting with bIncludeHeader set to false. (Just to see what would happen.) This exercise succeeded in crashing Omnis Studio v4.0. Needless to say I didn't bother testing any further.