Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
5
Erster Beitrag:
vor 4 Monaten, 3 Wochen
Letzter Beitrag:
vor 4 Monaten, 3 Wochen
Beteiligte Autoren:
ChristoK!, ccc2

Encryption/Decryption - external data...

Startbeitrag von ChristoK! am 28.03.2017 06:31

Greetings gang...

Does anyone know how to use CryptStandard and DecryptStandard to encrypt and decrypt data that comes from external locations (decrtyping keys and the like)???

I would very dearly like to know what the equivalent of the below would be in WX..

crypto.createHmac ('sha1', 'XXXX')
.update('xxx')
.digest('hex');

(I realise that that is a NodeJS wrapper for OpenSSL, but it is still something I need to know how to emulate)

Any assistance would be greatly appreciated.

C!!!

Antworten:

will generate hash
2FD8DC55DC052A22E386B554C591661BA1CFF3BC


------------- Node.JS --------------------

var text = 'This is a test';
var key = 'pass1';
var algorithm = 'sha1';
var hash, hmac;
hmac = crypto.createHmac(algorithm, key);

hmac.setEncoding('hex');

hmac.write(text);

hmac.end();

hash = hmac.read();

console.log(hash.toUpperCase());


--------------------- windev21 ------------

M_str is Buffer = StringToUTF8("This is a test")
m_key is Buffer = StringToUTF8("pass1" )

Info(NoSpace(BufferToHexa(HashString(HA_HMAC_SHA_160 , M_str , m_key )),sscAll) )

von ccc2 - am 28.03.2017 10:10
ccc2... that is brilliant thanks...

are you able to also show me how to decrypt back to "This is a test" ???

von ChristoK! - am 29.03.2017 02:59
HMAC-SHA1 is a one-way hash, not a bidirectional encryption algorithm. You can't decrypt it.

von ccc2 - am 29.03.2017 03:15
ccc2...

ok...

in that case...

my situation is I need to encrypt something at my end pass it to someone else so they can decrypt it (and vice versa)...

essentially what i need is the equivalent of the Crypt/Uncrypt functions that we use in WX for encrtyping/decrypting stuff that pass between myself and others (PHP and a Python developer)

I understand that CryptStandard/UncryptStandard are what I am supposed to use but I have as yet been unsuccessful with achieving this...

I am new to doing encryption/decryption between the platforms so any assistance is greatly appreciated...

von ChristoK! - am 29.03.2017 04:48
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.