Thanks for the tip. I got the solution with the following code.
1 $set ilusing"System.Security"
2 $set ilusing"System.Security.Cryptography"
3 class-id PasswordSHA.Form1 is partial
4 inherits type System.Windows.Forms.Form.
5
6 working-storage section.
7 1 wsHex string.
8 1 wsByteArray binary-char unsigned occurs any. *> Array Byte
9 1 wsHash binary-char unsigned occurs any. *> Array Byte
10 1 wsPassword pic x(20).
11
12 method-id NEW.
13 procedure division.
14 invoke self::InitializeComponent
15 goback.
16 end method.
17
18 *-----------------------------------------------------------------
19 *------------------ SHA1 -----------------------------------------
20 *-----------------------------------------------------------------
21 method-id button1_Click final private.
22 procedure division using by value sender as object e as type System.EventArgs.
23 try
24 declare mySHA1 SHA1Managed = new type SHA1Managed
25 set wsPassword to tbxIn::Text
26 set wsByteArray to wsPassword
27 set wsHash to mySHA1::ComputeHash(wsByteArray)
28 perform Create-string-hex
29 set tbxOut::Text to wsHex
30 catch ex as type Exception
31 invoke type MessageBox::Show("Erro: " & ex::Message)
32 end-try
33
34 goback.
35
36 Create-string-hex section.
37 set wsHex to ""
38 perform varying y as binary-char unsigned through wsHash
39 set wsHex to wsHex & String::Format("{0:x2}", y)
40 end-perform
41 end method.
42
43 *-----------------------------------------------------------------
44 *------------------ SHA512 ---------------------------------------
45 *-----------------------------------------------------------------
46 method-id button2_Click final private.
47 procedure division using by value sender as object e as type System.EventArgs.
48 //////////////////////////////////////////////////////////////////
49 /////////////////// Função em C# /////////////////////////////////
50 //////////////////////////////////////////////////////////////////
51
52 / private static string GetSHA512(string text)
53 / {
54 / UnicodeEncoding UE = new UnicodeEncoding();
55 / byte[] hashValue;
56 / byte[] message = UE.GetBytes(text);
57 /
58 / SHA512Managed hashString = new SHA512Managed();
59 / string hex = "";
60 /
61 / hashValue = hashString.ComputeHash(message);
62 / foreach (byte x in hashValue)
63 / {
64 / hex += String.Format("{0:x2}", x);
65 / }
66 / return hex;
67 / }
68
69 //////////////////////////////////////////////////////////////////
70 /////////// Convertida de C# para Visual Cobol ///////////////////
71 //////////////////////////////////////////////////////////////////
72
73 try
74 set wsPassword to tbxIn::Text
75 declare UE UnicodeEncoding = new UnicodeEncoding
76 declare hashValue as binary-char unsigned occurs any
77 declare myMessage = UE::GetBytes(wsPassword)
78 declare hashString SHA512Managed = new SHA512Managed
79 set hashValue to hashString::ComputeHash(myMessage)
80 set wsHex to ""
81 perform varying y as binary-char unsigned through hashValue
82 set wsHex to wsHex & String::Format("{0:x2}", y)
83 end-perform
84 catch ex as type Exception
85 invoke type MessageBox::Show("Erro: " & ex::Message)
86 end-try
87 set tbxOut::Text to wsHex
88 end method.
89
90 end class.