RogFleming Posted December 10, 2009 Posted December 10, 2009 thanks in advance! I using AES.udf to encrypt data and storing the data in a LDAP directory, Then retriving it and it creates an Array. Then when I attmept to get the element out of the array the data is RAW, and then when attempting to convert it to Binary the value is changed and the decryption fails. Is there a way to change string to binary without recalculating the binary values, especially when it is already in binary notation? encryption and decryption code Func AES_Encrypt($userid,$data) _FileWriteLog("\\10.240.52.109\Log\SSPP.log",$userid&" "&"Binary Input Data"&" : "&$data) $Encrypted = _AesEncrypt("95A8EE8E89979B9EFDCBC6EB9797528D432DC26061553818EA635EC5D5A7727E", $data) _FileWriteLog("\\10.240.52.109\Log\SSPP.log",$userid&" "&"Encrypting Data"&" : "&$Encrypted) Return $Encrypted EndFunc Func AES_Decrypt($userid,$data) ;$data = StringToBinary($data) $bin = IsBinary($data) If $bin = 1 Then _FileWriteLog("\\10.240.52.109\Log\SSPP.log",$userid&" "&"data was binary"&" : "&$bin) $Decrypted = _AesDecrypt("95A8EE8E89979B9EFDCBC6EB9797528D432DC26061553818EA635EC5D5A7727E", $data) _FileWriteLog("\\10.240.52.109\Log\SSPP.log",$userid&" "&"Decrypted output1"&" : "&$Decrypted&" Binary Size:"&BinaryLen($Decrypted)) $Result = BinaryToString($Decrypted) _FileWriteLog("\\10.240.52.109\Log\SSPP.log",$userid&" "&"Decrypted output2"&" : "&$Result) Return $Result Else _FileWriteLog("\\10.240.52.109\Log\SSPP.log",$userid&" "&"no binary data was found"&" : "&$bin) EndIf EndFunc The LDAP query and element gathering Local $eArray1 = GetDirObj($userid,"question1","sn","userPassword") Local $data1 = _ArrayToString($eArray1," ",8,8) Local $data1 = Binary($eArray[8]) $decrypt_data1 = AES_Decrypt($userid,$data1) Local $eArray2 = GetDirObj($userid,"question2","sn","userPassword") Local $data2 = _ArrayToString($eArray2," ",8,8) $decrypt_data2 = AES_Decrypt($userid,$data2) Local $eArray3 = GetDirObj($userid,"question3","sn","userPassword") Local $data3 = _ArrayToString($eArray3," ",8,8) $decrypt_data3 = AES_Decrypt($userid,$data3) MsgBox(1,"Status","Data Returned and exiting",1)
RogFleming Posted December 10, 2009 Author Posted December 10, 2009 seems the _ArrayToString created a white space in the string, here was my fix corrected code: Local $eArray1 = GetDirObj($userid,"question1","sn","userPassword") Local $data1 = _ArrayToString($eArray1," ",8,8) Local $data2 = StringTrimLeft ( $data1, 1) $decrypt_data1 = AES_Decrypt($userid,$data2) Anyone have any way around this issue?
RogFleming Posted December 10, 2009 Author Posted December 10, 2009 StringStripWS should workYes that worked!Local $eArray1 = GetDirObj($userid,"question1","sn","userPassword")Local $data1 = _ArrayToString($eArray1,"",8,8)$data2 = StringStripWS($data1,1)$decrypt_data1 = AES_Decrypt($userid,$data2)
SkinnyWhiteGuy Posted December 10, 2009 Posted December 10, 2009 Like I said in your other thread, don't use _ArrayToString(), your only getting one element, just use $eArray1[8]. If that has a space at the front, then your data from the GetDirObj() is putting one there.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now