Le forum (ô combien francophone) des utilisateurs de Powerbuilder.
Bonjour,
l'idée est
- d'avoir le mot de passe (mdp sql server) crypté dans le fichier .ini
- d'avoir dans le code Powerbuilder la clé de cryptage / décryptage
et d'utiliser ce package pour lire la clé cryptée dans le .ini, et la decrypter avant de la balancer à SQL server
j'ai fait une recherche sur le net:
http://www.topwizprogramming.com/freecode_crypto.html
Peut etre que le truc ce n'est pas terrible, mais pas mal de liens internet pointent sur cette PBL
pouvez vous me dire comment faire?
Merci
Dernière modification par moonella (24-09-2013 17:59:21)
Hors ligne
Bonjour,
Oui c'est une possibilité.
il y a aussi http://www.rgagnon.com/pbdetails/pb-0170.html
Hors ligne
Bonjour,
chez nous on est passé par une DLL maison écrite en C pour effectuer ça.
Maintenant, ce qu'il y a dans cette DLL, peu de développeurs le savent
Hors ligne
merci comme je suis nouvelle est ce que tu pourrai m aider un peut plus la dessus
j'ai ajouté le pbt crypto8.
et j'essaye d'utliser ses objets/fonctions
n_cryptoapi lnv_crypt
string ls_encrypted
lnv_crypt = CREATE n_cryptoapi
ls_encrypted = lnv_crypt.of_Encrypt(ls_logpass , "SecretKey")
DESTROY lnv_crypt
==> erreur de compilation
comment est ce je peut declarer un objet qui ne fait pas parti de ma solution
Hors ligne
Tu trouveras ci-dessous le code complet d'un composant de cryptage.
Très simple à utiliser.
Attention le composant hérite d'une classe nvo qui ne contient rien.
Le composant est auto_instancié
forward global type nvo_fcrypttools from nvo end type end forward global type nvo_fcrypttools from nvo autoinstantiate end type type prototypes PROTECTED: Function boolean & lext_CryptStringToBinary ( string pszString , & ulong cchString , & ulong dwFlags , & Ref blob pbBinary , & Ref ulong pcbBinary , & Ref ulong pdwSkip , & Ref ulong pdwFlags & ) Library "SP2AddOn.dll" Alias For "CryptStringToBinaryW" Function boolean & lext_CryptBinaryToString ( Blob pbBinary , & ulong cbBinary , & ulong dwFlags , & Ref string pszString , & Ref ulong pcchString & ) Library "SP2AddOn.dll" Alias For "CryptBinaryToStringW" end prototypes type variables PROTECTED: Protected string is_nvo_fcryptTools = Constant String i#_CryptKey = "$#@%&#%@&*" Constant Long i#_CriptStringBase64 = 1 Long il_keyCode =1 end variables forward prototypes public function string of_encoding (string as_stringtoencode, ref string as_returnmessage) protected function string of_encoding (blob ablob_data, ref string as_returnmessage) protected function blob of_decoding (string as_encoded) public function string of_decoding (string as_encoded, ref string as_returnmessage) public function string of_encrypt (string as_chaine) public function integer of_decrypt (string as_stringcrypte, ref string as_stringdecrypte) end prototypes public function string of_encoding (string as_stringtoencode, ref string as_returnmessage);//-------------------------------------------------------------------------------------------------------------------------------------------------- //---------------------------------- //---------------------------------- //--------------------------------- //-------------------------------- //------------------------------------------------------------------------------------------------------------------------------------------------- Long li_indice String ls_returnMessage String ls_null Blob lblob_dataToEncode String ls_stringEncoded SetNull(ls_null) lblob_dataToEncode = blob(as_stringtoencode) TRY For li_indice = 1 to il_keyCode ls_stringEncoded = of_encoding(lblob_dataToEncode,ls_returnMessage) lblob_dataToEncode = blob(ls_stringEncoded) If ls_returnMessage <> "OK" then return ls_null End if Next Return ls_stringEncoded CATCH (runtimeerror er) as_returnMessage = "Erreur dans la fonction of_encoding() de la classe " + this.className() + " (" + er.GetMessage() + ")" return ls_null End Try end function protected function string of_encoding (blob ablob_data, ref string as_returnmessage);//---------------------------------------------------------------------------------------------------------------------- //------------------------------- //------------------------------ //----------------------------- // //---------------------------- //--------------------------- //-------------------------------------------------------------------------------------------------------------------- String ls_null String ls_encoded ULong lul_len, lul_buflen Boolean lb_rtn as_returnmessage = "OK" SetNull(ls_null) lul_len = Len(ablob_data) lul_buflen = lul_len * 2 If lul_len <= 2 then as_returnMessage = return ls_null End if ls_encoded = Space(lul_buflen) lb_rtn = lext_CryptBinaryToString(ablob_data , & lul_len , & i#_CriptStringBase64 , & ls_encoded , & lul_buflen) If Not lb_rtn Then as_returnMessage = return ls_null End if Return ls_encoded end function protected function blob of_decoding (string as_encoded);//--------------------------------------------------------------------------------------------------------------------------------------- //------------------------------- //------------------------------ //----------------------------- //---------------------------- //-------------------------------------------------------------------------------------------------------------------------------------- Blob lblob_data // permet de transformer une chaine en blob Long ll_lenString ULong lul_buflen ULong lul_skip ULong lul_pflags Boolean lb_rtn ll_lenString = Len(as_encoded) lul_buflen = ll_lenString lblob_data = Blob(Space(ll_lenString)) lb_rtn = lext_CryptStringToBinary( as_encoded , & ll_lenString , & i#_CriptStringBase64 , & lblob_data , & lul_buflen , & lul_skip , & lul_pflags) Return BlobMid(lblob_data, 1, lul_buflen) end function public function string of_decoding (string as_encoded, ref string as_returnmessage);//-------------------------------------------------------------------------------------------------------------------------------------------------------- //---------------------------------- //---------------------------------- //--------------------------------- //-------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------------- Long li_indice String ls_stringDecode String ls_null SetNull(ls_null) ls_stringDecode = as_encoded TRY For li_indice = 1 to il_keyCode ls_stringDecode = String(of_decoding(ls_stringDecode)) Next Return ls_stringDecode CATCH (runtimeerror er) as_returnMessage = "Erreur dans la fonction of_decoding() de la classe " + this.className() + " (" + er.GetMessage() + ")" return ls_null End Try end function public function string of_encrypt (string as_chaine);//------------------------------------------------------------------------------------------------------------------------------------- //------------------------------- //------------------------------ //----------------------------- //---------------------------- //---------------------------- // la chaine avec le code suivant : // lblob = blob(ls_chaineCrypte) // ls_chaineCrypte = string(blobMid(lblob,1,len(string(lblob)))) //--------------------------------------------------------------------------------------------------------------------------------------- Integer li_indice Integer li_lenChaine String ls_chaineCrypte = "" Blob lblob li_lenChaine = len(as_chaine) For li_indice = 1 to li_lenChaine ls_chaineCrypte += mid(i#_CryptKey , mod(li_indice,10) + 1, 1) ls_chaineCrypte += String(Char(255 - Asc(Mid(as_chaine, li_indice, 1)))) Next Return ls_chaineCrypte end function public function integer of_decrypt (string as_stringcrypte, ref string as_stringdecrypte);//--------------------------------------------------------------------------------------------------------------------------------------------- //------------------------------- //------------------------------ // chaine vide sinon //----------------------------- //---------------------------- //----------------------------- //------------------------------------------------------------------------------------------------------------------------------------------------ Integer li_indice Integer li_lenChaineCrypte String ls_stringExtract // chaine d'extraction String ls_mid li_lenChaineCrypte = len(as_stringCrypte) IF not Mod(li_lenChaineCrypte, 2) = 1 then as_stringDecrypte = "" For li_indice = 2 to (li_lenChaineCrypte + 1) step 2 ls_stringExtract = Mid(as_stringCrypte, li_indice - 1, 1) ls_mid = mid(i#_CryptKey, Mod(li_indice / 2, 10) + 1, 1) If ls_mid <> ls_stringExtract then Return -1 End if ls_stringExtract = Mid(as_stringCrypte, li_indice, 1) as_stringDecrypte += string(char(255 - asc(ls_stringExtract))) Next End if Return 1 end function on nvo_fcrypttools.create call super::create end on on nvo_fcrypttools.destroy call super::destroy end on
Dernière modification par Dadone (24-09-2013 15:49:15)
Hors ligne
Dadone a écrit:
Tu trouveras ci-dessous le code complet d'un composant de cryptage.
Et la dll "sp2addon.dll" qui est utilisée par le code ?
Hors ligne
seki a écrit:
Dadone a écrit:
Tu trouveras ci-dessous le code complet d'un composant de cryptage.
Et la dll "sp2addon.dll" qui est utilisée par le code ?
Tu as raison les dll CryptStringToBinaryW et CryptBinaryToStringW font partie du Microsoft Developer Network (MSDN)
Si quelqu'un est intéressé je peux les lui fournir où y a t'il un moyen de les déposer sur le site ?
Sinon, elles sont récupérables sur le WEB.
Dernière modification par Dadone (24-09-2013 16:38:03)
Hors ligne
merci
Hors ligne