![]() ![]() If the user puts more than 32 characters for the password, no error will happen but only the first 32 will count. It's actually reasonably strong, simple as it is. That$ = DecryptPassword(this$, "somekey") This$ = EncryptPassword("Holy Smoke, Batman! ", "somekey") ProcedureReturn Trim(PeekS(*decodedtext, 32)) Remove any trailing spaces and return result Protected *decodedtext = AllocateMemory(33) 32 bytes for characters one byte for terminating Len(password$), *encodedbinary, 32) Convert the ascii encoded password back to binaryĪESDecoder(*encodedbinary, *decodedtext, 32, 128, 0, #PB_Cipher_ECB) Convert the encrypted password back to original Protected *encodedbinary = AllocateMemory(33) 32 bytes for data one safety byte Protected keyin$ = LSet(key$, 16, Chr(32)) key for 128bit decryption needs length=16 Procedure$ DecryptPassword(password$, key$) ProcedureReturn PeekS(*encodedtext) Return the completed ascii result Protected *encodedtext = AllocateMemory(64) Destination for Base64Encoder must be 33% larger- we double *encodedbinary, 32, 128, 0, #PB_Cipher_ECB) We don't encrypt the trailing zero so 32 bytes is enoughīase64Encoder(*encodedbinary, 32, *encodedtext, 64) Convert encrypted binary data to ascii for return Protected *encodedbinary = AllocateMemory(32) 32 bytes for encrypted binary result, see 2 lines down Protected keyin$ = LSet(key$, 16, Chr(32)) key for 128bit encryption needs length=16 Protected passin$ = LSet(password$, 32, Chr(32)) Pad the password with spaces to make 32 characters it is still much easier to handle with readily available routines in PB, so no wonder you will mostly find in the forums routines that make use of Base64 PB functions when dealing with encrypting/decrypting.Code: Select all Procedure$ EncryptPassword(password$, key$) Using Base64, even though it does make strings larger. and do all the handling of inserting/removing properly. The answer to your questions is definitely yes but one would need to use some nasty tricks (one option could be to replace any \0 with a very special sequence of bytes that's not available in the encrypted buffer. Is it possible to avoid Base64 encoding ? because it makes encrypted strings larger *mb1 = ReAllocateMemory(*mb1, n1) adjust size fo encrypted-buffer!ĭebug "> failed L = " Str(Len(org)) ProcedureReturn #False AES cant encrypt a memory block with size encrypted-buffer If AESDecoder(*Input, *Output, MemorySize(*Input), ?ENC_Key, 256, ?ENC_InitVect, #PB_Cipher_CBC) ProcedureReturn #False AES cant encrypt a memory block with size = 16) And (MemorySize(*Input) = MemorySize(*Output)) If AESEncoder(*Input, *Output, MemorySize(*Input), ?ENC_Key, 256, ?ENC_InitVect, #PB_Cipher_CBC) (If someone would nick my PC then he / she would not have my passwords and. If (MemorySize(*Input) >= 16) And (MemorySize(*Input) = MemorySize(*Output)) PureBasic is a commercially distributed procedural computer programming language and integrated development environment based on BASIC and developed by Fantaisie Software for Windows, Linux, and macOS. Ive stored it on my v-drive which actually is a TrueCrypt encrypted drive. encValue. some random generated data uisng CryptRandom() EndIf If the zip is AES encrypted (WinZip compatible) then the Encryption property will be equal to 4. Base64 is used to hide zero-bytes '\0' that could be generated by AES Code: Select all Encrypt/Decrypt any string using AES256-CBC Base64 ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |