WeixiangYan/CodeTransOcean huggingface dataset:
Task: Call an object method

C: #include<stdlib.h>
#include<stdio.h>

typedef struct{
        int x;
        int (*funcPtr)(int);
}functionPair;

int factorial(int num){
        if(num==0||num==1)
                return 1;
        else
                return num*factorial(num-1);
}

int main(int argc,char** argv)
{
        functionPair response;

        if(argc!=2)
                return printf("Usage : %s <non negative integer>",argv[0]);
        else{
                response = (functionPair){.x = atoi(argv[1]),.funcPtr=&factorial};
                printf("\nFactorial of %d is %d\n",response.x,response.funcPtr(response.x));
        }
        return 0;
}











Ada:    package My_Class is
      type Object is tagged private;
      procedure Primitive(Self: Object); 
      procedure Dynamic(Self: Object'Class);
      procedure Static;
   private
      type Object is tagged null record;
   end My_Class;
Task: Call an object method


C++: 
MyClass::method(someParameter);


myInstance.method(someParameter);


MyPointer->method(someParameter);










Ada:    package My_Class is
      type Object is tagged private;
      procedure Primitive(Self: Object); 
      procedure Dynamic(Self: Object'Class);
      procedure Static;
   private
      type Object is tagged null record;
   end My_Class;
Task: Call an object method




Go: type Foo int 


func (self Foo) ValueMethod(x int) { }


func (self *Foo) PointerMethod(x int) { }


var myValue Foo
var myPointer *Foo = new(Foo)


myValue.ValueMethod(someParameter)

myPointer.PointerMethod(someParameter)



myPointer.ValueMethod(someParameter)



myValue.PointerMethod(someParameter)


Foo.ValueMethod(myValue, someParameter)
(*Foo).PointerMethod(myPointer, someParameter)
(*Foo).ValueMethod(myPointer, someParameter)








Ada:    package My_Class is
      type Object is tagged private;
      procedure Primitive(Self: Object); 
      procedure Dynamic(Self: Object'Class);
      procedure Static;
   private
      type Object is tagged null record;
   end My_Class;
Task: Call an object method





Java: 
MyClass.method(someParameter);


myInstance.method(someParameter);







Ada:    package My_Class is
      type Object is tagged private;
      procedure Primitive(Self: Object); 
      procedure Dynamic(Self: Object'Class);
      procedure Static;
   private
      type Object is tagged null record;
   end My_Class;
Task: Call an object method







Python: class MyClass(object):
	@classmethod
	def myClassMethod(self, x):
		pass
	@staticmethod
	def myStaticMethod(x):
		pass
	def myMethod(self, x):
		return 42 + x

myInstance = MyClass()


myInstance.myMethod(someParameter)

MyClass.myMethod(myInstance, someParameter)



MyClass.myClassMethod(someParameter)
MyClass.myStaticMethod(someParameter)

myInstance.myClassMethod(someParameter)
myInstance.myStaticMethod(someParameter)





Ada:    package My_Class is
      type Object is tagged private;
      procedure Primitive(Self: Object); 
      procedure Dynamic(Self: Object'Class);
      procedure Static;
   private
      type Object is tagged null record;
   end My_Class;
Task: Call an object method








VB: Option Explicit

Sub Method_1(Optional myStr As String)
Dim strTemp As String
    If myStr <> "" Then strTemp = myStr
    Debug.Print strTemp
End Sub

Static Sub Method_2(Optional myStr As String)
Dim strTemp As String
    If myStr <> "" Then strTemp = myStr
    Debug.Print strTemp
End Sub




Ada:    package My_Class is
      type Object is tagged private;
      procedure Primitive(Self: Object); 
      procedure Dynamic(Self: Object'Class);
      procedure Static;
   private
      type Object is tagged null record;
   end My_Class;
Task: Call an object method

C: #include<stdlib.h>
#include<stdio.h>

typedef struct{
        int x;
        int (*funcPtr)(int);
}functionPair;

int factorial(int num){
        if(num==0||num==1)
                return 1;
        else
                return num*factorial(num-1);
}

int main(int argc,char** argv)
{
        functionPair response;

        if(argc!=2)
                return printf("Usage : %s <non negative integer>",argv[0]);
        else{
                response = (functionPair){.x = atoi(argv[1]),.funcPtr=&factorial};
                printf("\nFactorial of %d is %d\n",response.x,response.funcPtr(response.x));
        }
        return 0;
}
Task: Call an object method



C#: 
MyClass.Method(someParameter);
 

myInstance.Method(someParameter);
Task: Call an object method


C++: 
MyClass::method(someParameter);


myInstance.method(someParameter);


MyPointer->method(someParameter);
Task: Call an object method





Java: 
MyClass.method(someParameter);


myInstance.method(someParameter);
Task: Call an object method







Python: class MyClass(object):
	@classmethod
	def myClassMethod(self, x):
		pass
	@staticmethod
	def myStaticMethod(x):
		pass
	def myMethod(self, x):
		return 42 + x

myInstance = MyClass()


myInstance.myMethod(someParameter)

MyClass.myMethod(myInstance, someParameter)



MyClass.myClassMethod(someParameter)
MyClass.myStaticMethod(someParameter)

myInstance.myClassMethod(someParameter)
myInstance.myStaticMethod(someParameter)
Task: Call an object method








VB: Option Explicit

Sub Method_1(Optional myStr As String)
Dim strTemp As String
    If myStr <> "" Then strTemp = myStr
    Debug.Print strTemp
End Sub

Static Sub Method_2(Optional myStr As String)
Dim strTemp As String
    If myStr <> "" Then strTemp = myStr
    Debug.Print strTemp
End Sub
Task: Call an object method




Go: type Foo int 


func (self Foo) ValueMethod(x int) { }


func (self *Foo) PointerMethod(x int) { }


var myValue Foo
var myPointer *Foo = new(Foo)


myValue.ValueMethod(someParameter)

myPointer.PointerMethod(someParameter)



myPointer.ValueMethod(someParameter)



myValue.PointerMethod(someParameter)


Foo.ValueMethod(myValue, someParameter)
(*Foo).PointerMethod(myPointer, someParameter)
(*Foo).ValueMethod(myPointer, someParameter)
Task: Call an object method



C#: 
MyClass.Method(someParameter);
 

myInstance.Method(someParameter);








Fortran: 
type my_type
 contains
procedure, pass :: method1
procedure, pass, pointer :: method2
end type my_type


type(my_type) :: mytype_object


 call mytype_object%method1() 

 mytype_object%method2()
Task: Call an object method


C++: 
MyClass::method(someParameter);


myInstance.method(someParameter);


MyPointer->method(someParameter);









Fortran: 
type my_type
 contains
procedure, pass :: method1
procedure, pass, pointer :: method2
end type my_type


type(my_type) :: mytype_object


 call mytype_object%method1() 

 mytype_object%method2()
Task: Call an object method

C: #include<stdlib.h>
#include<stdio.h>

typedef struct{
        int x;
        int (*funcPtr)(int);
}functionPair;

int factorial(int num){
        if(num==0||num==1)
                return 1;
        else
                return num*factorial(num-1);
}

int main(int argc,char** argv)
{
        functionPair response;

        if(argc!=2)
                return printf("Usage : %s <non negative integer>",argv[0]);
        else{
                response = (functionPair){.x = atoi(argv[1]),.funcPtr=&factorial};
                printf("\nFactorial of %d is %d\n",response.x,response.funcPtr(response.x));
        }
        return 0;
}










Fortran: 
type my_type
 contains
procedure, pass :: method1
procedure, pass, pointer :: method2
end type my_type


type(my_type) :: mytype_object


 call mytype_object%method1() 

 mytype_object%method2()
Task: Call an object method





Java: 
MyClass.method(someParameter);


myInstance.method(someParameter);






Fortran: 
type my_type
 contains
procedure, pass :: method1
procedure, pass, pointer :: method2
end type my_type


type(my_type) :: mytype_object


 call mytype_object%method1() 

 mytype_object%method2()
Task: Call an object method







Python: class MyClass(object):
	@classmethod
	def myClassMethod(self, x):
		pass
	@staticmethod
	def myStaticMethod(x):
		pass
	def myMethod(self, x):
		return 42 + x

myInstance = MyClass()


myInstance.myMethod(someParameter)

MyClass.myMethod(myInstance, someParameter)



MyClass.myClassMethod(someParameter)
MyClass.myStaticMethod(someParameter)

myInstance.myClassMethod(someParameter)
myInstance.myStaticMethod(someParameter)




Fortran: 
type my_type
 contains
procedure, pass :: method1
procedure, pass, pointer :: method2
end type my_type


type(my_type) :: mytype_object


 call mytype_object%method1() 

 mytype_object%method2()
Task: Call an object method








VB: Option Explicit

Sub Method_1(Optional myStr As String)
Dim strTemp As String
    If myStr <> "" Then strTemp = myStr
    Debug.Print strTemp
End Sub

Static Sub Method_2(Optional myStr As String)
Dim strTemp As String
    If myStr <> "" Then strTemp = myStr
    Debug.Print strTemp
End Sub



Fortran: 
type my_type
 contains
procedure, pass :: method1
procedure, pass, pointer :: method2
end type my_type


type(my_type) :: mytype_object


 call mytype_object%method1() 

 mytype_object%method2()
Task: Call an object method






PHP: 
MyClass::method($someParameter);

$foo = 'MyClass';
$foo::method($someParameter);

$myInstance->method($someParameter);





Fortran: 
type my_type
 contains
procedure, pass :: method1
procedure, pass, pointer :: method2
end type my_type


type(my_type) :: mytype_object


 call mytype_object%method1() 

 mytype_object%method2()
Task: Call an object method

C: #include<stdlib.h>
#include<stdio.h>

typedef struct{
        int x;
        int (*funcPtr)(int);
}functionPair;

int factorial(int num){
        if(num==0||num==1)
                return 1;
        else
                return num*factorial(num-1);
}

int main(int argc,char** argv)
{
        functionPair response;

        if(argc!=2)
                return printf("Usage : %s <non negative integer>",argv[0]);
        else{
                response = (functionPair){.x = atoi(argv[1]),.funcPtr=&factorial};
                printf("\nFactorial of %d is %d\n",response.x,response.funcPtr(response.x));
        }
        return 0;
}









COBOL: 
INVOKE FooClass "someMethod" RETURNING bar        
INVOKE foo-instance "anotherMethod" RETURNING bar 


MOVE FooClass::"someMethod" TO bar        
MOVE foo-instance::"anotherMethod" TO bar
Task: Call an object method



C#: 
MyClass.Method(someParameter);
 

myInstance.Method(someParameter);







COBOL: 
INVOKE FooClass "someMethod" RETURNING bar        
INVOKE foo-instance "anotherMethod" RETURNING bar 


MOVE FooClass::"someMethod" TO bar        
MOVE foo-instance::"anotherMethod" TO bar
Task: Call an object method


C++: 
MyClass::method(someParameter);


myInstance.method(someParameter);


MyPointer->method(someParameter);








COBOL: 
INVOKE FooClass "someMethod" RETURNING bar        
INVOKE foo-instance "anotherMethod" RETURNING bar 


MOVE FooClass::"someMethod" TO bar        
MOVE foo-instance::"anotherMethod" TO bar
Task: Call an object method





Java: 
MyClass.method(someParameter);


myInstance.method(someParameter);





COBOL: 
INVOKE FooClass "someMethod" RETURNING bar        
INVOKE foo-instance "anotherMethod" RETURNING bar 


MOVE FooClass::"someMethod" TO bar        
MOVE foo-instance::"anotherMethod" TO bar
Task: Call an object method







Python: class MyClass(object):
	@classmethod
	def myClassMethod(self, x):
		pass
	@staticmethod
	def myStaticMethod(x):
		pass
	def myMethod(self, x):
		return 42 + x

myInstance = MyClass()


myInstance.myMethod(someParameter)

MyClass.myMethod(myInstance, someParameter)



MyClass.myClassMethod(someParameter)
MyClass.myStaticMethod(someParameter)

myInstance.myClassMethod(someParameter)
myInstance.myStaticMethod(someParameter)



COBOL: 
INVOKE FooClass "someMethod" RETURNING bar        
INVOKE foo-instance "anotherMethod" RETURNING bar 


MOVE FooClass::"someMethod" TO bar        
MOVE foo-instance::"anotherMethod" TO bar
Task: Call an object method








VB: Option Explicit

Sub Method_1(Optional myStr As String)
Dim strTemp As String
    If myStr <> "" Then strTemp = myStr
    Debug.Print strTemp
End Sub

Static Sub Method_2(Optional myStr As String)
Dim strTemp As String
    If myStr <> "" Then strTemp = myStr
    Debug.Print strTemp
End Sub


COBOL: 
INVOKE FooClass "someMethod" RETURNING bar        
INVOKE foo-instance "anotherMethod" RETURNING bar 


MOVE FooClass::"someMethod" TO bar        
MOVE foo-instance::"anotherMethod" TO bar
Task: Call an object method




Go: type Foo int 


func (self Foo) ValueMethod(x int) { }


func (self *Foo) PointerMethod(x int) { }


var myValue Foo
var myPointer *Foo = new(Foo)


myValue.ValueMethod(someParameter)

myPointer.PointerMethod(someParameter)



myPointer.ValueMethod(someParameter)



myValue.PointerMethod(someParameter)


Foo.ValueMethod(myValue, someParameter)
(*Foo).PointerMethod(myPointer, someParameter)
(*Foo).ValueMethod(myPointer, someParameter)






COBOL: 
INVOKE FooClass "someMethod" RETURNING bar        
INVOKE foo-instance "anotherMethod" RETURNING bar 


MOVE FooClass::"someMethod" TO bar        
MOVE foo-instance::"anotherMethod" TO bar
Task: Call an object method






PHP: 
MyClass::method($someParameter);

$foo = 'MyClass';
$foo::method($someParameter);

$myInstance->method($someParameter);
Task: Call an object method






PHP: 
MyClass::method($someParameter);

$foo = 'MyClass';
$foo::method($someParameter);

$myInstance->method($someParameter);






Ada:    package My_Class is
      type Object is tagged private;
      procedure Primitive(Self: Object); 
      procedure Dynamic(Self: Object'Class);
      procedure Static;
   private
      type Object is tagged null record;
   end My_Class;
Task: Call an object method






PHP: 
MyClass::method($someParameter);

$foo = 'MyClass';
$foo::method($someParameter);

$myInstance->method($someParameter);




COBOL: 
INVOKE FooClass "someMethod" RETURNING bar        
INVOKE foo-instance "anotherMethod" RETURNING bar 


MOVE FooClass::"someMethod" TO bar        
MOVE foo-instance::"anotherMethod" TO bar
Task: SHA-256



C#: using System;
using System.Security.Cryptography;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace RosettaCode.SHA256
{
    [TestClass]
    public class SHA256ManagedTest
    {
        [TestMethod]
        public void TestComputeHash()
        {
            var buffer = Encoding.UTF8.GetBytes("Rosetta code");
            var hashAlgorithm = new SHA256Managed();
            var hash = hashAlgorithm.ComputeHash(buffer);
            Assert.AreEqual(
                "76-4F-AF-5C-61-AC-31-5F-14-97-F9-DF-A5-42-71-39-65-B7-85-E5-CC-2F-70-7D-64-68-D7-D1-12-4C-DF-CF",
                BitConverter.ToString(hash));
        }
    }
}









Ada: with Ada.Text_IO;

with CryptAda.Pragmatics;
with CryptAda.Digests.Message_Digests.SHA_256;
with CryptAda.Digests.Hashes;
with CryptAda.Utils.Format;

procedure RC_SHA_256 is
   use CryptAda.Pragmatics;
   use CryptAda.Digests.Message_Digests;
   use CryptAda.Digests;

   function To_Byte_Array (Item : String) return Byte_Array is
      Result : Byte_Array (Item'Range);
   begin
      for I in Result'Range loop
         Result (I) := Byte (Character'Pos (Item (I)));
      end loop;
      return Result;
   end To_Byte_Array;

   Text    : constant String                := "Rosetta code";
   Bytes   : constant Byte_Array            := To_Byte_Array (Text);
   Handle  : constant Message_Digest_Handle := SHA_256.Get_Message_Digest_Handle;
   Pointer : constant Message_Digest_Ptr    := Get_Message_Digest_Ptr (Handle);
   Hash    : Hashes.Hash;
begin
   Digest_Start  (Pointer);
   Digest_Update (Pointer, Bytes);
   Digest_End    (Pointer, Hash);

   Ada.Text_IO.Put_Line
     ("""" & Text & """: " & CryptAda.Utils.Format.To_Hex_String (Hashes.Get_Bytes (Hash)));
end RC_SHA_256;
Task: SHA-256

C: #include <stdio.h>
#include <string.h>
#include <openssl/sha.h>

int main (void) {
	const char *s = "Rosetta code";
	unsigned char *d = SHA256(s, strlen(s), 0);

	int i;
	for (i = 0; i < SHA256_DIGEST_LENGTH; i++)
		printf("%02x", d[i]);
	putchar('\n');

	return 0;
}











Ada: with Ada.Text_IO;

with CryptAda.Pragmatics;
with CryptAda.Digests.Message_Digests.SHA_256;
with CryptAda.Digests.Hashes;
with CryptAda.Utils.Format;

procedure RC_SHA_256 is
   use CryptAda.Pragmatics;
   use CryptAda.Digests.Message_Digests;
   use CryptAda.Digests;

   function To_Byte_Array (Item : String) return Byte_Array is
      Result : Byte_Array (Item'Range);
   begin
      for I in Result'Range loop
         Result (I) := Byte (Character'Pos (Item (I)));
      end loop;
      return Result;
   end To_Byte_Array;

   Text    : constant String                := "Rosetta code";
   Bytes   : constant Byte_Array            := To_Byte_Array (Text);
   Handle  : constant Message_Digest_Handle := SHA_256.Get_Message_Digest_Handle;
   Pointer : constant Message_Digest_Ptr    := Get_Message_Digest_Ptr (Handle);
   Hash    : Hashes.Hash;
begin
   Digest_Start  (Pointer);
   Digest_Update (Pointer, Bytes);
   Digest_End    (Pointer, Hash);

   Ada.Text_IO.Put_Line
     ("""" & Text & """: " & CryptAda.Utils.Format.To_Hex_String (Hashes.Get_Bytes (Hash)));
end RC_SHA_256;
Task: SHA-256


C++: #include <iostream>
#include <cryptopp/filters.h>
#include <cryptopp/hex.h>
#include <cryptopp/sha.h>

int main(int argc, char **argv){
	CryptoPP::SHA256 hash;
	std::string digest;
	std::string message = "Rosetta code";

	CryptoPP::StringSource s(message, true,
			new CryptoPP::HashFilter(hash,
				new CryptoPP::HexEncoder(
					new CryptoPP::StringSink(digest))));

	std::cout << digest << std::endl;

	return 0;
}










Ada: with Ada.Text_IO;

with CryptAda.Pragmatics;
with CryptAda.Digests.Message_Digests.SHA_256;
with CryptAda.Digests.Hashes;
with CryptAda.Utils.Format;

procedure RC_SHA_256 is
   use CryptAda.Pragmatics;
   use CryptAda.Digests.Message_Digests;
   use CryptAda.Digests;

   function To_Byte_Array (Item : String) return Byte_Array is
      Result : Byte_Array (Item'Range);
   begin
      for I in Result'Range loop
         Result (I) := Byte (Character'Pos (Item (I)));
      end loop;
      return Result;
   end To_Byte_Array;

   Text    : constant String                := "Rosetta code";
   Bytes   : constant Byte_Array            := To_Byte_Array (Text);
   Handle  : constant Message_Digest_Handle := SHA_256.Get_Message_Digest_Handle;
   Pointer : constant Message_Digest_Ptr    := Get_Message_Digest_Ptr (Handle);
   Hash    : Hashes.Hash;
begin
   Digest_Start  (Pointer);
   Digest_Update (Pointer, Bytes);
   Digest_End    (Pointer, Hash);

   Ada.Text_IO.Put_Line
     ("""" & Text & """: " & CryptAda.Utils.Format.To_Hex_String (Hashes.Get_Bytes (Hash)));
end RC_SHA_256;
Task: SHA-256




Go: package main

import (
    "crypto/sha256"
    "fmt"
    "log"
)

func main() {
    h := sha256.New()
    if _, err := h.Write([]byte("Rosetta code")); err != nil {
        log.Fatal(err)
    }
    fmt.Printf("%x\n", h.Sum(nil))
}








Ada: with Ada.Text_IO;

with CryptAda.Pragmatics;
with CryptAda.Digests.Message_Digests.SHA_256;
with CryptAda.Digests.Hashes;
with CryptAda.Utils.Format;

procedure RC_SHA_256 is
   use CryptAda.Pragmatics;
   use CryptAda.Digests.Message_Digests;
   use CryptAda.Digests;

   function To_Byte_Array (Item : String) return Byte_Array is
      Result : Byte_Array (Item'Range);
   begin
      for I in Result'Range loop
         Result (I) := Byte (Character'Pos (Item (I)));
      end loop;
      return Result;
   end To_Byte_Array;

   Text    : constant String                := "Rosetta code";
   Bytes   : constant Byte_Array            := To_Byte_Array (Text);
   Handle  : constant Message_Digest_Handle := SHA_256.Get_Message_Digest_Handle;
   Pointer : constant Message_Digest_Ptr    := Get_Message_Digest_Ptr (Handle);
   Hash    : Hashes.Hash;
begin
   Digest_Start  (Pointer);
   Digest_Update (Pointer, Bytes);
   Digest_End    (Pointer, Hash);

   Ada.Text_IO.Put_Line
     ("""" & Text & """: " & CryptAda.Utils.Format.To_Hex_String (Hashes.Get_Bytes (Hash)));
end RC_SHA_256;
Task: SHA-256







Python: >>> import hashlib
>>> hashlib.sha256( "Rosetta code".encode() ).hexdigest()
'764faf5c61ac315f1497f9dfa542713965b785e5cc2f707d6468d7d1124cdfcf'
>>>





Ada: with Ada.Text_IO;

with CryptAda.Pragmatics;
with CryptAda.Digests.Message_Digests.SHA_256;
with CryptAda.Digests.Hashes;
with CryptAda.Utils.Format;

procedure RC_SHA_256 is
   use CryptAda.Pragmatics;
   use CryptAda.Digests.Message_Digests;
   use CryptAda.Digests;

   function To_Byte_Array (Item : String) return Byte_Array is
      Result : Byte_Array (Item'Range);
   begin
      for I in Result'Range loop
         Result (I) := Byte (Character'Pos (Item (I)));
      end loop;
      return Result;
   end To_Byte_Array;

   Text    : constant String                := "Rosetta code";
   Bytes   : constant Byte_Array            := To_Byte_Array (Text);
   Handle  : constant Message_Digest_Handle := SHA_256.Get_Message_Digest_Handle;
   Pointer : constant Message_Digest_Ptr    := Get_Message_Digest_Ptr (Handle);
   Hash    : Hashes.Hash;
begin
   Digest_Start  (Pointer);
   Digest_Update (Pointer, Bytes);
   Digest_End    (Pointer, Hash);

   Ada.Text_IO.Put_Line
     ("""" & Text & """: " & CryptAda.Utils.Format.To_Hex_String (Hashes.Get_Bytes (Hash)));
end RC_SHA_256;
Task: SHA-256

C: #include <stdio.h>
#include <string.h>
#include <openssl/sha.h>

int main (void) {
	const char *s = "Rosetta code";
	unsigned char *d = SHA256(s, strlen(s), 0);

	int i;
	for (i = 0; i < SHA256_DIGEST_LENGTH; i++)
		printf("%02x", d[i]);
	putchar('\n');

	return 0;
}
Task: SHA-256



C#: using System;
using System.Security.Cryptography;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace RosettaCode.SHA256
{
    [TestClass]
    public class SHA256ManagedTest
    {
        [TestMethod]
        public void TestComputeHash()
        {
            var buffer = Encoding.UTF8.GetBytes("Rosetta code");
            var hashAlgorithm = new SHA256Managed();
            var hash = hashAlgorithm.ComputeHash(buffer);
            Assert.AreEqual(
                "76-4F-AF-5C-61-AC-31-5F-14-97-F9-DF-A5-42-71-39-65-B7-85-E5-CC-2F-70-7D-64-68-D7-D1-12-4C-DF-CF",
                BitConverter.ToString(hash));
        }
    }
}
Task: SHA-256


C++: #include <iostream>
#include <cryptopp/filters.h>
#include <cryptopp/hex.h>
#include <cryptopp/sha.h>

int main(int argc, char **argv){
	CryptoPP::SHA256 hash;
	std::string digest;
	std::string message = "Rosetta code";

	CryptoPP::StringSource s(message, true,
			new CryptoPP::HashFilter(hash,
				new CryptoPP::HexEncoder(
					new CryptoPP::StringSink(digest))));

	std::cout << digest << std::endl;

	return 0;
}
Task: SHA-256







Python: >>> import hashlib
>>> hashlib.sha256( "Rosetta code".encode() ).hexdigest()
'764faf5c61ac315f1497f9dfa542713965b785e5cc2f707d6468d7d1124cdfcf'
>>>
Task: SHA-256




Go: package main

import (
    "crypto/sha256"
    "fmt"
    "log"
)

func main() {
    h := sha256.New()
    if _, err := h.Write([]byte("Rosetta code")); err != nil {
        log.Fatal(err)
    }
    fmt.Printf("%x\n", h.Sum(nil))
}