Instruction
stringlengths
45
106
input_code
stringlengths
1
13.7k
output_code
stringlengths
1
13.7k
Please provide an equivalent version of this D code in C#.
void main() { import std.stdio, std.bigint, std.algorithm, std.string, std.range, modular_exponentiation; immutable txt = "Rosetta Code"; writeln("Plain text: ", txt); immutable BigInt n = "2463574872878749457479".BigInt * "386280601842257...
using System; using System.Numerics; using System.Text; class Program { static void Main(string[] args) { BigInteger n = BigInteger.Parse("9516311845790656153499716760847001433441357"); BigInteger e = 65537; BigInteger d = BigInteger.Parse("5617843187844953170308463622230283376298685");...
Ensure the translated Java code behaves exactly like the original D snippet.
void main() { import std.stdio, std.bigint, std.algorithm, std.string, std.range, modular_exponentiation; immutable txt = "Rosetta Code"; writeln("Plain text: ", txt); immutable BigInt n = "2463574872878749457479".BigInt * "386280601842257...
public static void main(String[] args) { BigInteger n = new BigInteger("9516311845790656153499716760847001433441357"); BigInteger e = new BigInteger("65537"); BigInteger d = new BigInteger("5617843187844953170308463622230283376298685"); Charset c = Charsets.UTF_8; String plainText = "Rosetta Co...
Translate the given D code snippet into Python without altering its behavior.
void main() { import std.stdio, std.bigint, std.algorithm, std.string, std.range, modular_exponentiation; immutable txt = "Rosetta Code"; writeln("Plain text: ", txt); immutable BigInt n = "2463574872878749457479".BigInt * "386280601842257...
import binascii n = 9516311845790656153499716760847001433441357 e = 65537 d = 5617843187844953170308463622230283376298685 message='Rosetta Code!' print('message ', message) hex_data = binascii.hexlify(message.encode()) print('hex data ', hex_data) plain_text = int(hex_data, 16) ...
Write the same algorithm in VB as shown in this D implementation.
void main() { import std.stdio, std.bigint, std.algorithm, std.string, std.range, modular_exponentiation; immutable txt = "Rosetta Code"; writeln("Plain text: ", txt); immutable BigInt n = "2463574872878749457479".BigInt * "386280601842257...
Imports System Imports System.Numerics Imports System.Text Module Module1 Sub Main() Dim n As BigInteger = BigInteger.Parse("9516311845790656153499716760847001433441357") Dim e As BigInteger = 65537 Dim d As BigInteger = BigInteger.Parse("5617843187844953170308463622230283376298685") ...
Rewrite the snippet below in Go so it works the same as the original D code.
void main() { import std.stdio, std.bigint, std.algorithm, std.string, std.range, modular_exponentiation; immutable txt = "Rosetta Code"; writeln("Plain text: ", txt); immutable BigInt n = "2463574872878749457479".BigInt * "386280601842257...
package main import ( "fmt" "math/big" ) func main() { var n, e, d, bb, ptn, etn, dtn big.Int pt := "Rosetta Code" fmt.Println("Plain text: ", pt) n.SetString("9516311845790656153499716760847001433441357", 10) e.SetString("65537", 10) d.SetString("56178431878...
Port the provided Delphi code into C while preserving the original functionality.
program RSA_code; uses System.SysUtils, Velthuis.BigIntegers; type TRSA = record private n, e, d: BigInteger; class function PlainTextAsNumber(data: AnsiString): BigInteger; static; class function NumberAsPlainText(Num: BigInteger): AnsiString; static; public constructor Create(n, e, d: st...
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <gmp.h> int main(void) { mpz_t n, d, e, pt, ct; mpz_init(pt); mpz_init(ct); mpz_init_set_str(n, "9516311845790656153499716760847001433441357", 10); mpz_init_set_str(e, "65537", 10); mpz_init_set_str(d, "56178431878449531703084...
Convert this Delphi block to C#, preserving its control flow and logic.
program RSA_code; uses System.SysUtils, Velthuis.BigIntegers; type TRSA = record private n, e, d: BigInteger; class function PlainTextAsNumber(data: AnsiString): BigInteger; static; class function NumberAsPlainText(Num: BigInteger): AnsiString; static; public constructor Create(n, e, d: st...
using System; using System.Numerics; using System.Text; class Program { static void Main(string[] args) { BigInteger n = BigInteger.Parse("9516311845790656153499716760847001433441357"); BigInteger e = 65537; BigInteger d = BigInteger.Parse("5617843187844953170308463622230283376298685");...
Generate a Java translation of this Delphi snippet without changing its computational steps.
program RSA_code; uses System.SysUtils, Velthuis.BigIntegers; type TRSA = record private n, e, d: BigInteger; class function PlainTextAsNumber(data: AnsiString): BigInteger; static; class function NumberAsPlainText(Num: BigInteger): AnsiString; static; public constructor Create(n, e, d: st...
public static void main(String[] args) { BigInteger n = new BigInteger("9516311845790656153499716760847001433441357"); BigInteger e = new BigInteger("65537"); BigInteger d = new BigInteger("5617843187844953170308463622230283376298685"); Charset c = Charsets.UTF_8; String plainText = "Rosetta Co...
Convert this Delphi block to Python, preserving its control flow and logic.
program RSA_code; uses System.SysUtils, Velthuis.BigIntegers; type TRSA = record private n, e, d: BigInteger; class function PlainTextAsNumber(data: AnsiString): BigInteger; static; class function NumberAsPlainText(Num: BigInteger): AnsiString; static; public constructor Create(n, e, d: st...
import binascii n = 9516311845790656153499716760847001433441357 e = 65537 d = 5617843187844953170308463622230283376298685 message='Rosetta Code!' print('message ', message) hex_data = binascii.hexlify(message.encode()) print('hex data ', hex_data) plain_text = int(hex_data, 16) ...
Produce a functionally identical VB code for the snippet given in Delphi.
program RSA_code; uses System.SysUtils, Velthuis.BigIntegers; type TRSA = record private n, e, d: BigInteger; class function PlainTextAsNumber(data: AnsiString): BigInteger; static; class function NumberAsPlainText(Num: BigInteger): AnsiString; static; public constructor Create(n, e, d: st...
Imports System Imports System.Numerics Imports System.Text Module Module1 Sub Main() Dim n As BigInteger = BigInteger.Parse("9516311845790656153499716760847001433441357") Dim e As BigInteger = 65537 Dim d As BigInteger = BigInteger.Parse("5617843187844953170308463622230283376298685") ...
Write the same code in Go as shown below in Delphi.
program RSA_code; uses System.SysUtils, Velthuis.BigIntegers; type TRSA = record private n, e, d: BigInteger; class function PlainTextAsNumber(data: AnsiString): BigInteger; static; class function NumberAsPlainText(Num: BigInteger): AnsiString; static; public constructor Create(n, e, d: st...
package main import ( "fmt" "math/big" ) func main() { var n, e, d, bb, ptn, etn, dtn big.Int pt := "Rosetta Code" fmt.Println("Plain text: ", pt) n.SetString("9516311845790656153499716760847001433441357", 10) e.SetString("65537", 10) d.SetString("56178431878...
Convert the following code from Erlang to C, ensuring the logic remains intact.
-module mod. -export [mod_mult/3,mod_exp/3,binary_exp/2,test/0]. mod_mult(I1,I2,Mod) when I1 > Mod, is_integer(I1), is_integer(I2), is_integer(Mod) -> mod_mult(I1 rem Mod,I2,Mod); mod_mult(I1,I2,Mod) when I2 > Mod, is_integer(I1), is_integer(I2), is_integer(Mod) -> mod_mult(I1,...
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <gmp.h> int main(void) { mpz_t n, d, e, pt, ct; mpz_init(pt); mpz_init(ct); mpz_init_set_str(n, "9516311845790656153499716760847001433441357", 10); mpz_init_set_str(e, "65537", 10); mpz_init_set_str(d, "56178431878449531703084...
Convert this Erlang snippet to C# and keep its semantics consistent.
-module mod. -export [mod_mult/3,mod_exp/3,binary_exp/2,test/0]. mod_mult(I1,I2,Mod) when I1 > Mod, is_integer(I1), is_integer(I2), is_integer(Mod) -> mod_mult(I1 rem Mod,I2,Mod); mod_mult(I1,I2,Mod) when I2 > Mod, is_integer(I1), is_integer(I2), is_integer(Mod) -> mod_mult(I1,...
using System; using System.Numerics; using System.Text; class Program { static void Main(string[] args) { BigInteger n = BigInteger.Parse("9516311845790656153499716760847001433441357"); BigInteger e = 65537; BigInteger d = BigInteger.Parse("5617843187844953170308463622230283376298685");...
Generate a Java translation of this Erlang snippet without changing its computational steps.
-module mod. -export [mod_mult/3,mod_exp/3,binary_exp/2,test/0]. mod_mult(I1,I2,Mod) when I1 > Mod, is_integer(I1), is_integer(I2), is_integer(Mod) -> mod_mult(I1 rem Mod,I2,Mod); mod_mult(I1,I2,Mod) when I2 > Mod, is_integer(I1), is_integer(I2), is_integer(Mod) -> mod_mult(I1,...
public static void main(String[] args) { BigInteger n = new BigInteger("9516311845790656153499716760847001433441357"); BigInteger e = new BigInteger("65537"); BigInteger d = new BigInteger("5617843187844953170308463622230283376298685"); Charset c = Charsets.UTF_8; String plainText = "Rosetta Co...
Write a version of this Erlang function in Python with identical behavior.
-module mod. -export [mod_mult/3,mod_exp/3,binary_exp/2,test/0]. mod_mult(I1,I2,Mod) when I1 > Mod, is_integer(I1), is_integer(I2), is_integer(Mod) -> mod_mult(I1 rem Mod,I2,Mod); mod_mult(I1,I2,Mod) when I2 > Mod, is_integer(I1), is_integer(I2), is_integer(Mod) -> mod_mult(I1,...
import binascii n = 9516311845790656153499716760847001433441357 e = 65537 d = 5617843187844953170308463622230283376298685 message='Rosetta Code!' print('message ', message) hex_data = binascii.hexlify(message.encode()) print('hex data ', hex_data) plain_text = int(hex_data, 16) ...
Write a version of this Erlang function in VB with identical behavior.
-module mod. -export [mod_mult/3,mod_exp/3,binary_exp/2,test/0]. mod_mult(I1,I2,Mod) when I1 > Mod, is_integer(I1), is_integer(I2), is_integer(Mod) -> mod_mult(I1 rem Mod,I2,Mod); mod_mult(I1,I2,Mod) when I2 > Mod, is_integer(I1), is_integer(I2), is_integer(Mod) -> mod_mult(I1,...
Imports System Imports System.Numerics Imports System.Text Module Module1 Sub Main() Dim n As BigInteger = BigInteger.Parse("9516311845790656153499716760847001433441357") Dim e As BigInteger = 65537 Dim d As BigInteger = BigInteger.Parse("5617843187844953170308463622230283376298685") ...
Convert this Erlang block to Go, preserving its control flow and logic.
-module mod. -export [mod_mult/3,mod_exp/3,binary_exp/2,test/0]. mod_mult(I1,I2,Mod) when I1 > Mod, is_integer(I1), is_integer(I2), is_integer(Mod) -> mod_mult(I1 rem Mod,I2,Mod); mod_mult(I1,I2,Mod) when I2 > Mod, is_integer(I1), is_integer(I2), is_integer(Mod) -> mod_mult(I1,...
package main import ( "fmt" "math/big" ) func main() { var n, e, d, bb, ptn, etn, dtn big.Int pt := "Rosetta Code" fmt.Println("Plain text: ", pt) n.SetString("9516311845790656153499716760847001433441357", 10) e.SetString("65537", 10) d.SetString("56178431878...
Convert this F# block to C, preserving its control flow and logic.
let RSA n g l = bigint.ModPow(l,n,g) let encrypt = RSA 65537I 9516311845790656153499716760847001433441357I let m_in = System.Text.Encoding.ASCII.GetBytes "The magic words are SQUEAMISH OSSIFRAGE"|>Array.chunkBySize 16|>Array.map(Array.fold(fun n g ->(n*256I)+(bigint(int g))) 0I) let n = Array.map encrypt m_in let decr...
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <gmp.h> int main(void) { mpz_t n, d, e, pt, ct; mpz_init(pt); mpz_init(ct); mpz_init_set_str(n, "9516311845790656153499716760847001433441357", 10); mpz_init_set_str(e, "65537", 10); mpz_init_set_str(d, "56178431878449531703084...
Change the following F# code into C# without altering its purpose.
let RSA n g l = bigint.ModPow(l,n,g) let encrypt = RSA 65537I 9516311845790656153499716760847001433441357I let m_in = System.Text.Encoding.ASCII.GetBytes "The magic words are SQUEAMISH OSSIFRAGE"|>Array.chunkBySize 16|>Array.map(Array.fold(fun n g ->(n*256I)+(bigint(int g))) 0I) let n = Array.map encrypt m_in let decr...
using System; using System.Numerics; using System.Text; class Program { static void Main(string[] args) { BigInteger n = BigInteger.Parse("9516311845790656153499716760847001433441357"); BigInteger e = 65537; BigInteger d = BigInteger.Parse("5617843187844953170308463622230283376298685");...
Ensure the translated Java code behaves exactly like the original F# snippet.
let RSA n g l = bigint.ModPow(l,n,g) let encrypt = RSA 65537I 9516311845790656153499716760847001433441357I let m_in = System.Text.Encoding.ASCII.GetBytes "The magic words are SQUEAMISH OSSIFRAGE"|>Array.chunkBySize 16|>Array.map(Array.fold(fun n g ->(n*256I)+(bigint(int g))) 0I) let n = Array.map encrypt m_in let decr...
public static void main(String[] args) { BigInteger n = new BigInteger("9516311845790656153499716760847001433441357"); BigInteger e = new BigInteger("65537"); BigInteger d = new BigInteger("5617843187844953170308463622230283376298685"); Charset c = Charsets.UTF_8; String plainText = "Rosetta Co...
Generate a Python translation of this F# snippet without changing its computational steps.
let RSA n g l = bigint.ModPow(l,n,g) let encrypt = RSA 65537I 9516311845790656153499716760847001433441357I let m_in = System.Text.Encoding.ASCII.GetBytes "The magic words are SQUEAMISH OSSIFRAGE"|>Array.chunkBySize 16|>Array.map(Array.fold(fun n g ->(n*256I)+(bigint(int g))) 0I) let n = Array.map encrypt m_in let decr...
import binascii n = 9516311845790656153499716760847001433441357 e = 65537 d = 5617843187844953170308463622230283376298685 message='Rosetta Code!' print('message ', message) hex_data = binascii.hexlify(message.encode()) print('hex data ', hex_data) plain_text = int(hex_data, 16) ...
Convert the following code from F# to VB, ensuring the logic remains intact.
let RSA n g l = bigint.ModPow(l,n,g) let encrypt = RSA 65537I 9516311845790656153499716760847001433441357I let m_in = System.Text.Encoding.ASCII.GetBytes "The magic words are SQUEAMISH OSSIFRAGE"|>Array.chunkBySize 16|>Array.map(Array.fold(fun n g ->(n*256I)+(bigint(int g))) 0I) let n = Array.map encrypt m_in let decr...
Imports System Imports System.Numerics Imports System.Text Module Module1 Sub Main() Dim n As BigInteger = BigInteger.Parse("9516311845790656153499716760847001433441357") Dim e As BigInteger = 65537 Dim d As BigInteger = BigInteger.Parse("5617843187844953170308463622230283376298685") ...
Convert this F# block to Go, preserving its control flow and logic.
let RSA n g l = bigint.ModPow(l,n,g) let encrypt = RSA 65537I 9516311845790656153499716760847001433441357I let m_in = System.Text.Encoding.ASCII.GetBytes "The magic words are SQUEAMISH OSSIFRAGE"|>Array.chunkBySize 16|>Array.map(Array.fold(fun n g ->(n*256I)+(bigint(int g))) 0I) let n = Array.map encrypt m_in let decr...
package main import ( "fmt" "math/big" ) func main() { var n, e, d, bb, ptn, etn, dtn big.Int pt := "Rosetta Code" fmt.Println("Plain text: ", pt) n.SetString("9516311845790656153499716760847001433441357", 10) e.SetString("65537", 10) d.SetString("56178431878...
Produce a functionally identical C code for the snippet given in Haskell.
module RSAMaker where import Data.Char ( chr ) encode :: String -> [Integer] encode s = map (toInteger . fromEnum ) s rsa_encode :: Integer -> Integer -> [Integer] -> [Integer] rsa_encode n e numbers = map (\num -> mod ( num ^ e ) n ) numbers rsa_decode :: Integer -> Integer -> [Integer] -> [Integer] rsa_decode ...
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <gmp.h> int main(void) { mpz_t n, d, e, pt, ct; mpz_init(pt); mpz_init(ct); mpz_init_set_str(n, "9516311845790656153499716760847001433441357", 10); mpz_init_set_str(e, "65537", 10); mpz_init_set_str(d, "56178431878449531703084...
Convert this Haskell block to Java, preserving its control flow and logic.
module RSAMaker where import Data.Char ( chr ) encode :: String -> [Integer] encode s = map (toInteger . fromEnum ) s rsa_encode :: Integer -> Integer -> [Integer] -> [Integer] rsa_encode n e numbers = map (\num -> mod ( num ^ e ) n ) numbers rsa_decode :: Integer -> Integer -> [Integer] -> [Integer] rsa_decode ...
public static void main(String[] args) { BigInteger n = new BigInteger("9516311845790656153499716760847001433441357"); BigInteger e = new BigInteger("65537"); BigInteger d = new BigInteger("5617843187844953170308463622230283376298685"); Charset c = Charsets.UTF_8; String plainText = "Rosetta Co...
Transform the following Haskell implementation into Python, maintaining the same output and logic.
module RSAMaker where import Data.Char ( chr ) encode :: String -> [Integer] encode s = map (toInteger . fromEnum ) s rsa_encode :: Integer -> Integer -> [Integer] -> [Integer] rsa_encode n e numbers = map (\num -> mod ( num ^ e ) n ) numbers rsa_decode :: Integer -> Integer -> [Integer] -> [Integer] rsa_decode ...
import binascii n = 9516311845790656153499716760847001433441357 e = 65537 d = 5617843187844953170308463622230283376298685 message='Rosetta Code!' print('message ', message) hex_data = binascii.hexlify(message.encode()) print('hex data ', hex_data) plain_text = int(hex_data, 16) ...
Translate this program into VB but keep the logic exactly as in Haskell.
module RSAMaker where import Data.Char ( chr ) encode :: String -> [Integer] encode s = map (toInteger . fromEnum ) s rsa_encode :: Integer -> Integer -> [Integer] -> [Integer] rsa_encode n e numbers = map (\num -> mod ( num ^ e ) n ) numbers rsa_decode :: Integer -> Integer -> [Integer] -> [Integer] rsa_decode ...
Imports System Imports System.Numerics Imports System.Text Module Module1 Sub Main() Dim n As BigInteger = BigInteger.Parse("9516311845790656153499716760847001433441357") Dim e As BigInteger = 65537 Dim d As BigInteger = BigInteger.Parse("5617843187844953170308463622230283376298685") ...
Generate a Go translation of this Haskell snippet without changing its computational steps.
module RSAMaker where import Data.Char ( chr ) encode :: String -> [Integer] encode s = map (toInteger . fromEnum ) s rsa_encode :: Integer -> Integer -> [Integer] -> [Integer] rsa_encode n e numbers = map (\num -> mod ( num ^ e ) n ) numbers rsa_decode :: Integer -> Integer -> [Integer] -> [Integer] rsa_decode ...
package main import ( "fmt" "math/big" ) func main() { var n, e, d, bb, ptn, etn, dtn big.Int pt := "Rosetta Code" fmt.Println("Plain text: ", pt) n.SetString("9516311845790656153499716760847001433441357", 10) e.SetString("65537", 10) d.SetString("56178431878...
Port the provided Icon code into C while preserving the original functionality.
procedure main() n := 9516311845790656153499716760847001433441357 e := 65537 d := 5617843187844953170308463622230283376298685 b := 2^integer(log(n,2)) write("RSA Demo using\n n = ",n,"\n e = ",e,"\n d = ",d,"\n b = ",b) every m := !["Rosetta Code", "Hello Word!", ...
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <gmp.h> int main(void) { mpz_t n, d, e, pt, ct; mpz_init(pt); mpz_init(ct); mpz_init_set_str(n, "9516311845790656153499716760847001433441357", 10); mpz_init_set_str(e, "65537", 10); mpz_init_set_str(d, "56178431878449531703084...
Convert this Icon block to C#, preserving its control flow and logic.
procedure main() n := 9516311845790656153499716760847001433441357 e := 65537 d := 5617843187844953170308463622230283376298685 b := 2^integer(log(n,2)) write("RSA Demo using\n n = ",n,"\n e = ",e,"\n d = ",d,"\n b = ",b) every m := !["Rosetta Code", "Hello Word!", ...
using System; using System.Numerics; using System.Text; class Program { static void Main(string[] args) { BigInteger n = BigInteger.Parse("9516311845790656153499716760847001433441357"); BigInteger e = 65537; BigInteger d = BigInteger.Parse("5617843187844953170308463622230283376298685");...
Convert this Icon block to Java, preserving its control flow and logic.
procedure main() n := 9516311845790656153499716760847001433441357 e := 65537 d := 5617843187844953170308463622230283376298685 b := 2^integer(log(n,2)) write("RSA Demo using\n n = ",n,"\n e = ",e,"\n d = ",d,"\n b = ",b) every m := !["Rosetta Code", "Hello Word!", ...
public static void main(String[] args) { BigInteger n = new BigInteger("9516311845790656153499716760847001433441357"); BigInteger e = new BigInteger("65537"); BigInteger d = new BigInteger("5617843187844953170308463622230283376298685"); Charset c = Charsets.UTF_8; String plainText = "Rosetta Co...
Rewrite this program in Python while keeping its functionality equivalent to the Icon version.
procedure main() n := 9516311845790656153499716760847001433441357 e := 65537 d := 5617843187844953170308463622230283376298685 b := 2^integer(log(n,2)) write("RSA Demo using\n n = ",n,"\n e = ",e,"\n d = ",d,"\n b = ",b) every m := !["Rosetta Code", "Hello Word!", ...
import binascii n = 9516311845790656153499716760847001433441357 e = 65537 d = 5617843187844953170308463622230283376298685 message='Rosetta Code!' print('message ', message) hex_data = binascii.hexlify(message.encode()) print('hex data ', hex_data) plain_text = int(hex_data, 16) ...
Maintain the same structure and functionality when rewriting this code in VB.
procedure main() n := 9516311845790656153499716760847001433441357 e := 65537 d := 5617843187844953170308463622230283376298685 b := 2^integer(log(n,2)) write("RSA Demo using\n n = ",n,"\n e = ",e,"\n d = ",d,"\n b = ",b) every m := !["Rosetta Code", "Hello Word!", ...
Imports System Imports System.Numerics Imports System.Text Module Module1 Sub Main() Dim n As BigInteger = BigInteger.Parse("9516311845790656153499716760847001433441357") Dim e As BigInteger = 65537 Dim d As BigInteger = BigInteger.Parse("5617843187844953170308463622230283376298685") ...
Transform the following Icon implementation into Go, maintaining the same output and logic.
procedure main() n := 9516311845790656153499716760847001433441357 e := 65537 d := 5617843187844953170308463622230283376298685 b := 2^integer(log(n,2)) write("RSA Demo using\n n = ",n,"\n e = ",e,"\n d = ",d,"\n b = ",b) every m := !["Rosetta Code", "Hello Word!", ...
package main import ( "fmt" "math/big" ) func main() { var n, e, d, bb, ptn, etn, dtn big.Int pt := "Rosetta Code" fmt.Println("Plain text: ", pt) n.SetString("9516311845790656153499716760847001433441357", 10) e.SetString("65537", 10) d.SetString("56178431878...
Generate a C translation of this J snippet without changing its computational steps.
N=: 9516311845790656153499716760847001433441357x E=: 65537x D=: 5617843187844953170308463622230283376298685x ] text=: 'Rosetta Code' Rosetta Code ] num=: 256x #. a.i.text 25512506514985639724585018469 num >: N 0 ] enc=: N&|@^&E num 916709442744356653386978770799029131264344 ] dec=: N&|@^&D...
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <gmp.h> int main(void) { mpz_t n, d, e, pt, ct; mpz_init(pt); mpz_init(ct); mpz_init_set_str(n, "9516311845790656153499716760847001433441357", 10); mpz_init_set_str(e, "65537", 10); mpz_init_set_str(d, "56178431878449531703084...
Write the same algorithm in C# as shown in this J implementation.
N=: 9516311845790656153499716760847001433441357x E=: 65537x D=: 5617843187844953170308463622230283376298685x ] text=: 'Rosetta Code' Rosetta Code ] num=: 256x #. a.i.text 25512506514985639724585018469 num >: N 0 ] enc=: N&|@^&E num 916709442744356653386978770799029131264344 ] dec=: N&|@^&D...
using System; using System.Numerics; using System.Text; class Program { static void Main(string[] args) { BigInteger n = BigInteger.Parse("9516311845790656153499716760847001433441357"); BigInteger e = 65537; BigInteger d = BigInteger.Parse("5617843187844953170308463622230283376298685");...
Port the provided J code into Java while preserving the original functionality.
N=: 9516311845790656153499716760847001433441357x E=: 65537x D=: 5617843187844953170308463622230283376298685x ] text=: 'Rosetta Code' Rosetta Code ] num=: 256x #. a.i.text 25512506514985639724585018469 num >: N 0 ] enc=: N&|@^&E num 916709442744356653386978770799029131264344 ] dec=: N&|@^&D...
public static void main(String[] args) { BigInteger n = new BigInteger("9516311845790656153499716760847001433441357"); BigInteger e = new BigInteger("65537"); BigInteger d = new BigInteger("5617843187844953170308463622230283376298685"); Charset c = Charsets.UTF_8; String plainText = "Rosetta Co...
Convert this J snippet to Python and keep its semantics consistent.
N=: 9516311845790656153499716760847001433441357x E=: 65537x D=: 5617843187844953170308463622230283376298685x ] text=: 'Rosetta Code' Rosetta Code ] num=: 256x #. a.i.text 25512506514985639724585018469 num >: N 0 ] enc=: N&|@^&E num 916709442744356653386978770799029131264344 ] dec=: N&|@^&D...
import binascii n = 9516311845790656153499716760847001433441357 e = 65537 d = 5617843187844953170308463622230283376298685 message='Rosetta Code!' print('message ', message) hex_data = binascii.hexlify(message.encode()) print('hex data ', hex_data) plain_text = int(hex_data, 16) ...
Change the programming language of this snippet from J to VB without modifying what it does.
N=: 9516311845790656153499716760847001433441357x E=: 65537x D=: 5617843187844953170308463622230283376298685x ] text=: 'Rosetta Code' Rosetta Code ] num=: 256x #. a.i.text 25512506514985639724585018469 num >: N 0 ] enc=: N&|@^&E num 916709442744356653386978770799029131264344 ] dec=: N&|@^&D...
Imports System Imports System.Numerics Imports System.Text Module Module1 Sub Main() Dim n As BigInteger = BigInteger.Parse("9516311845790656153499716760847001433441357") Dim e As BigInteger = 65537 Dim d As BigInteger = BigInteger.Parse("5617843187844953170308463622230283376298685") ...
Change the programming language of this snippet from J to Go without modifying what it does.
N=: 9516311845790656153499716760847001433441357x E=: 65537x D=: 5617843187844953170308463622230283376298685x ] text=: 'Rosetta Code' Rosetta Code ] num=: 256x #. a.i.text 25512506514985639724585018469 num >: N 0 ] enc=: N&|@^&E num 916709442744356653386978770799029131264344 ] dec=: N&|@^&D...
package main import ( "fmt" "math/big" ) func main() { var n, e, d, bb, ptn, etn, dtn big.Int pt := "Rosetta Code" fmt.Println("Plain text: ", pt) n.SetString("9516311845790656153499716760847001433441357", 10) e.SetString("65537", 10) d.SetString("56178431878...
Maintain the same structure and functionality when rewriting this code in C.
function rsaencode(clearmsg::AbstractString, nmod::Integer, expub::Integer) bytes = parse(BigInt, "0x" * bytes2hex(collect(UInt8, clearmsg))) return powermod(bytes, expub, nmod) end function rsadecode(cryptmsg::Integer, nmod::Integer, dsecr::Integer) decoded = powermod(encoded, dsecr, nmod) return join...
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <gmp.h> int main(void) { mpz_t n, d, e, pt, ct; mpz_init(pt); mpz_init(ct); mpz_init_set_str(n, "9516311845790656153499716760847001433441357", 10); mpz_init_set_str(e, "65537", 10); mpz_init_set_str(d, "56178431878449531703084...
Maintain the same structure and functionality when rewriting this code in C#.
function rsaencode(clearmsg::AbstractString, nmod::Integer, expub::Integer) bytes = parse(BigInt, "0x" * bytes2hex(collect(UInt8, clearmsg))) return powermod(bytes, expub, nmod) end function rsadecode(cryptmsg::Integer, nmod::Integer, dsecr::Integer) decoded = powermod(encoded, dsecr, nmod) return join...
using System; using System.Numerics; using System.Text; class Program { static void Main(string[] args) { BigInteger n = BigInteger.Parse("9516311845790656153499716760847001433441357"); BigInteger e = 65537; BigInteger d = BigInteger.Parse("5617843187844953170308463622230283376298685");...
Generate an equivalent Java version of this Julia code.
function rsaencode(clearmsg::AbstractString, nmod::Integer, expub::Integer) bytes = parse(BigInt, "0x" * bytes2hex(collect(UInt8, clearmsg))) return powermod(bytes, expub, nmod) end function rsadecode(cryptmsg::Integer, nmod::Integer, dsecr::Integer) decoded = powermod(encoded, dsecr, nmod) return join...
public static void main(String[] args) { BigInteger n = new BigInteger("9516311845790656153499716760847001433441357"); BigInteger e = new BigInteger("65537"); BigInteger d = new BigInteger("5617843187844953170308463622230283376298685"); Charset c = Charsets.UTF_8; String plainText = "Rosetta Co...
Can you help me rewrite this code in Python instead of Julia, keeping it the same logically?
function rsaencode(clearmsg::AbstractString, nmod::Integer, expub::Integer) bytes = parse(BigInt, "0x" * bytes2hex(collect(UInt8, clearmsg))) return powermod(bytes, expub, nmod) end function rsadecode(cryptmsg::Integer, nmod::Integer, dsecr::Integer) decoded = powermod(encoded, dsecr, nmod) return join...
import binascii n = 9516311845790656153499716760847001433441357 e = 65537 d = 5617843187844953170308463622230283376298685 message='Rosetta Code!' print('message ', message) hex_data = binascii.hexlify(message.encode()) print('hex data ', hex_data) plain_text = int(hex_data, 16) ...
Change the following Julia code into VB without altering its purpose.
function rsaencode(clearmsg::AbstractString, nmod::Integer, expub::Integer) bytes = parse(BigInt, "0x" * bytes2hex(collect(UInt8, clearmsg))) return powermod(bytes, expub, nmod) end function rsadecode(cryptmsg::Integer, nmod::Integer, dsecr::Integer) decoded = powermod(encoded, dsecr, nmod) return join...
Imports System Imports System.Numerics Imports System.Text Module Module1 Sub Main() Dim n As BigInteger = BigInteger.Parse("9516311845790656153499716760847001433441357") Dim e As BigInteger = 65537 Dim d As BigInteger = BigInteger.Parse("5617843187844953170308463622230283376298685") ...
Keep all operations the same but rewrite the snippet in Go.
function rsaencode(clearmsg::AbstractString, nmod::Integer, expub::Integer) bytes = parse(BigInt, "0x" * bytes2hex(collect(UInt8, clearmsg))) return powermod(bytes, expub, nmod) end function rsadecode(cryptmsg::Integer, nmod::Integer, dsecr::Integer) decoded = powermod(encoded, dsecr, nmod) return join...
package main import ( "fmt" "math/big" ) func main() { var n, e, d, bb, ptn, etn, dtn big.Int pt := "Rosetta Code" fmt.Println("Plain text: ", pt) n.SetString("9516311845790656153499716760847001433441357", 10) e.SetString("65537", 10) d.SetString("56178431878...
Port the following code from Nim to C with equivalent syntax and logic.
import strutils, streams, strformat import stint const messages = ["PPAP", "I have a pen, I have a apple\nUh! Apple-pen!", "I have a pen, I have pineapple\nUh! Pineapple-pen!", "Apple-pen, pineapple-pen\nUh! Pen-pineapple-apple-pen\nPen-pineapple-apple-pen\nDance time!", "\a\0"] const n = u256("951631184579...
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <gmp.h> int main(void) { mpz_t n, d, e, pt, ct; mpz_init(pt); mpz_init(ct); mpz_init_set_str(n, "9516311845790656153499716760847001433441357", 10); mpz_init_set_str(e, "65537", 10); mpz_init_set_str(d, "56178431878449531703084...
Translate this program into C# but keep the logic exactly as in Nim.
import strutils, streams, strformat import stint const messages = ["PPAP", "I have a pen, I have a apple\nUh! Apple-pen!", "I have a pen, I have pineapple\nUh! Pineapple-pen!", "Apple-pen, pineapple-pen\nUh! Pen-pineapple-apple-pen\nPen-pineapple-apple-pen\nDance time!", "\a\0"] const n = u256("951631184579...
using System; using System.Numerics; using System.Text; class Program { static void Main(string[] args) { BigInteger n = BigInteger.Parse("9516311845790656153499716760847001433441357"); BigInteger e = 65537; BigInteger d = BigInteger.Parse("5617843187844953170308463622230283376298685");...
Preserve the algorithm and functionality while converting the code from Nim to Java.
import strutils, streams, strformat import stint const messages = ["PPAP", "I have a pen, I have a apple\nUh! Apple-pen!", "I have a pen, I have pineapple\nUh! Pineapple-pen!", "Apple-pen, pineapple-pen\nUh! Pen-pineapple-apple-pen\nPen-pineapple-apple-pen\nDance time!", "\a\0"] const n = u256("951631184579...
public static void main(String[] args) { BigInteger n = new BigInteger("9516311845790656153499716760847001433441357"); BigInteger e = new BigInteger("65537"); BigInteger d = new BigInteger("5617843187844953170308463622230283376298685"); Charset c = Charsets.UTF_8; String plainText = "Rosetta Co...
Please provide an equivalent version of this Nim code in Python.
import strutils, streams, strformat import stint const messages = ["PPAP", "I have a pen, I have a apple\nUh! Apple-pen!", "I have a pen, I have pineapple\nUh! Pineapple-pen!", "Apple-pen, pineapple-pen\nUh! Pen-pineapple-apple-pen\nPen-pineapple-apple-pen\nDance time!", "\a\0"] const n = u256("951631184579...
import binascii n = 9516311845790656153499716760847001433441357 e = 65537 d = 5617843187844953170308463622230283376298685 message='Rosetta Code!' print('message ', message) hex_data = binascii.hexlify(message.encode()) print('hex data ', hex_data) plain_text = int(hex_data, 16) ...
Transform the following Nim implementation into VB, maintaining the same output and logic.
import strutils, streams, strformat import stint const messages = ["PPAP", "I have a pen, I have a apple\nUh! Apple-pen!", "I have a pen, I have pineapple\nUh! Pineapple-pen!", "Apple-pen, pineapple-pen\nUh! Pen-pineapple-apple-pen\nPen-pineapple-apple-pen\nDance time!", "\a\0"] const n = u256("951631184579...
Imports System Imports System.Numerics Imports System.Text Module Module1 Sub Main() Dim n As BigInteger = BigInteger.Parse("9516311845790656153499716760847001433441357") Dim e As BigInteger = 65537 Dim d As BigInteger = BigInteger.Parse("5617843187844953170308463622230283376298685") ...
Maintain the same structure and functionality when rewriting this code in Go.
import strutils, streams, strformat import stint const messages = ["PPAP", "I have a pen, I have a apple\nUh! Apple-pen!", "I have a pen, I have pineapple\nUh! Pineapple-pen!", "Apple-pen, pineapple-pen\nUh! Pen-pineapple-apple-pen\nPen-pineapple-apple-pen\nDance time!", "\a\0"] const n = u256("951631184579...
package main import ( "fmt" "math/big" ) func main() { var n, e, d, bb, ptn, etn, dtn big.Int pt := "Rosetta Code" fmt.Println("Plain text: ", pt) n.SetString("9516311845790656153499716760847001433441357", 10) e.SetString("65537", 10) d.SetString("56178431878...
Port the provided Perl code into C while preserving the original functionality.
use bigint; $n = 9516311845790656153499716760847001433441357; $e = 65537; $d = 5617843187844953170308463622230283376298685; package Message { my @alphabet; push @alphabet, $_ for 'A' .. 'Z', ' '; my $rad = +@alphabet; $code{$alphabet[$_]} = $_ for 0..$rad-1; sub encode { my($t) = @_; ...
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <gmp.h> int main(void) { mpz_t n, d, e, pt, ct; mpz_init(pt); mpz_init(ct); mpz_init_set_str(n, "9516311845790656153499716760847001433441357", 10); mpz_init_set_str(e, "65537", 10); mpz_init_set_str(d, "56178431878449531703084...
Change the following Perl code into C# without altering its purpose.
use bigint; $n = 9516311845790656153499716760847001433441357; $e = 65537; $d = 5617843187844953170308463622230283376298685; package Message { my @alphabet; push @alphabet, $_ for 'A' .. 'Z', ' '; my $rad = +@alphabet; $code{$alphabet[$_]} = $_ for 0..$rad-1; sub encode { my($t) = @_; ...
using System; using System.Numerics; using System.Text; class Program { static void Main(string[] args) { BigInteger n = BigInteger.Parse("9516311845790656153499716760847001433441357"); BigInteger e = 65537; BigInteger d = BigInteger.Parse("5617843187844953170308463622230283376298685");...
Preserve the algorithm and functionality while converting the code from Perl to Java.
use bigint; $n = 9516311845790656153499716760847001433441357; $e = 65537; $d = 5617843187844953170308463622230283376298685; package Message { my @alphabet; push @alphabet, $_ for 'A' .. 'Z', ' '; my $rad = +@alphabet; $code{$alphabet[$_]} = $_ for 0..$rad-1; sub encode { my($t) = @_; ...
public static void main(String[] args) { BigInteger n = new BigInteger("9516311845790656153499716760847001433441357"); BigInteger e = new BigInteger("65537"); BigInteger d = new BigInteger("5617843187844953170308463622230283376298685"); Charset c = Charsets.UTF_8; String plainText = "Rosetta Co...
Preserve the algorithm and functionality while converting the code from Perl to Python.
use bigint; $n = 9516311845790656153499716760847001433441357; $e = 65537; $d = 5617843187844953170308463622230283376298685; package Message { my @alphabet; push @alphabet, $_ for 'A' .. 'Z', ' '; my $rad = +@alphabet; $code{$alphabet[$_]} = $_ for 0..$rad-1; sub encode { my($t) = @_; ...
import binascii n = 9516311845790656153499716760847001433441357 e = 65537 d = 5617843187844953170308463622230283376298685 message='Rosetta Code!' print('message ', message) hex_data = binascii.hexlify(message.encode()) print('hex data ', hex_data) plain_text = int(hex_data, 16) ...
Change the programming language of this snippet from Perl to VB without modifying what it does.
use bigint; $n = 9516311845790656153499716760847001433441357; $e = 65537; $d = 5617843187844953170308463622230283376298685; package Message { my @alphabet; push @alphabet, $_ for 'A' .. 'Z', ' '; my $rad = +@alphabet; $code{$alphabet[$_]} = $_ for 0..$rad-1; sub encode { my($t) = @_; ...
Imports System Imports System.Numerics Imports System.Text Module Module1 Sub Main() Dim n As BigInteger = BigInteger.Parse("9516311845790656153499716760847001433441357") Dim e As BigInteger = 65537 Dim d As BigInteger = BigInteger.Parse("5617843187844953170308463622230283376298685") ...
Please provide an equivalent version of this Perl code in Go.
use bigint; $n = 9516311845790656153499716760847001433441357; $e = 65537; $d = 5617843187844953170308463622230283376298685; package Message { my @alphabet; push @alphabet, $_ for 'A' .. 'Z', ' '; my $rad = +@alphabet; $code{$alphabet[$_]} = $_ for 0..$rad-1; sub encode { my($t) = @_; ...
package main import ( "fmt" "math/big" ) func main() { var n, e, d, bb, ptn, etn, dtn big.Int pt := "Rosetta Code" fmt.Println("Plain text: ", pt) n.SetString("9516311845790656153499716760847001433441357", 10) e.SetString("65537", 10) d.SetString("56178431878...
Ensure the translated C code behaves exactly like the original PowerShell snippet.
$n = [BigInt]::Parse("9516311845790656153499716760847001433441357") $e = [BigInt]::new(65537) $d = [BigInt]::Parse("5617843187844953170308463622230283376298685") $plaintextstring = "Hello, Rosetta!" $plaintext = [Text.ASCIIEncoding]::ASCII.GetBytes($plaintextstring) [BigInt]$pt = [BigInt]::new($plaintext) if ($n -lt $p...
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <gmp.h> int main(void) { mpz_t n, d, e, pt, ct; mpz_init(pt); mpz_init(ct); mpz_init_set_str(n, "9516311845790656153499716760847001433441357", 10); mpz_init_set_str(e, "65537", 10); mpz_init_set_str(d, "56178431878449531703084...
Please provide an equivalent version of this PowerShell code in C#.
$n = [BigInt]::Parse("9516311845790656153499716760847001433441357") $e = [BigInt]::new(65537) $d = [BigInt]::Parse("5617843187844953170308463622230283376298685") $plaintextstring = "Hello, Rosetta!" $plaintext = [Text.ASCIIEncoding]::ASCII.GetBytes($plaintextstring) [BigInt]$pt = [BigInt]::new($plaintext) if ($n -lt $p...
using System; using System.Numerics; using System.Text; class Program { static void Main(string[] args) { BigInteger n = BigInteger.Parse("9516311845790656153499716760847001433441357"); BigInteger e = 65537; BigInteger d = BigInteger.Parse("5617843187844953170308463622230283376298685");...
Generate an equivalent Java version of this PowerShell code.
$n = [BigInt]::Parse("9516311845790656153499716760847001433441357") $e = [BigInt]::new(65537) $d = [BigInt]::Parse("5617843187844953170308463622230283376298685") $plaintextstring = "Hello, Rosetta!" $plaintext = [Text.ASCIIEncoding]::ASCII.GetBytes($plaintextstring) [BigInt]$pt = [BigInt]::new($plaintext) if ($n -lt $p...
public static void main(String[] args) { BigInteger n = new BigInteger("9516311845790656153499716760847001433441357"); BigInteger e = new BigInteger("65537"); BigInteger d = new BigInteger("5617843187844953170308463622230283376298685"); Charset c = Charsets.UTF_8; String plainText = "Rosetta Co...
Convert the following code from PowerShell to Python, ensuring the logic remains intact.
$n = [BigInt]::Parse("9516311845790656153499716760847001433441357") $e = [BigInt]::new(65537) $d = [BigInt]::Parse("5617843187844953170308463622230283376298685") $plaintextstring = "Hello, Rosetta!" $plaintext = [Text.ASCIIEncoding]::ASCII.GetBytes($plaintextstring) [BigInt]$pt = [BigInt]::new($plaintext) if ($n -lt $p...
import binascii n = 9516311845790656153499716760847001433441357 e = 65537 d = 5617843187844953170308463622230283376298685 message='Rosetta Code!' print('message ', message) hex_data = binascii.hexlify(message.encode()) print('hex data ', hex_data) plain_text = int(hex_data, 16) ...
Write the same algorithm in VB as shown in this PowerShell implementation.
$n = [BigInt]::Parse("9516311845790656153499716760847001433441357") $e = [BigInt]::new(65537) $d = [BigInt]::Parse("5617843187844953170308463622230283376298685") $plaintextstring = "Hello, Rosetta!" $plaintext = [Text.ASCIIEncoding]::ASCII.GetBytes($plaintextstring) [BigInt]$pt = [BigInt]::new($plaintext) if ($n -lt $p...
Imports System Imports System.Numerics Imports System.Text Module Module1 Sub Main() Dim n As BigInteger = BigInteger.Parse("9516311845790656153499716760847001433441357") Dim e As BigInteger = 65537 Dim d As BigInteger = BigInteger.Parse("5617843187844953170308463622230283376298685") ...
Maintain the same structure and functionality when rewriting this code in Go.
$n = [BigInt]::Parse("9516311845790656153499716760847001433441357") $e = [BigInt]::new(65537) $d = [BigInt]::Parse("5617843187844953170308463622230283376298685") $plaintextstring = "Hello, Rosetta!" $plaintext = [Text.ASCIIEncoding]::ASCII.GetBytes($plaintextstring) [BigInt]$pt = [BigInt]::new($plaintext) if ($n -lt $p...
package main import ( "fmt" "math/big" ) func main() { var n, e, d, bb, ptn, etn, dtn big.Int pt := "Rosetta Code" fmt.Println("Plain text: ", pt) n.SetString("9516311845790656153499716760847001433441357", 10) e.SetString("65537", 10) d.SetString("56178431878...
Rewrite this program in C while keeping its functionality equivalent to the Racket version.
#lang racket (require math/number-theory) (define-logger rsa) (current-logger rsa-logger) (define (bytes->number B) (for/fold ((rv 0)) ((b B)) (+ b (* rv 256)))) (define (number->bytes N) (define (inr n b) (if (zero? n) b (inr (quotient n 256) (bytes-append (bytes (modulo n 256)) b)))) (inr N (bytes))) (d...
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <gmp.h> int main(void) { mpz_t n, d, e, pt, ct; mpz_init(pt); mpz_init(ct); mpz_init_set_str(n, "9516311845790656153499716760847001433441357", 10); mpz_init_set_str(e, "65537", 10); mpz_init_set_str(d, "56178431878449531703084...
Can you help me rewrite this code in C# instead of Racket, keeping it the same logically?
#lang racket (require math/number-theory) (define-logger rsa) (current-logger rsa-logger) (define (bytes->number B) (for/fold ((rv 0)) ((b B)) (+ b (* rv 256)))) (define (number->bytes N) (define (inr n b) (if (zero? n) b (inr (quotient n 256) (bytes-append (bytes (modulo n 256)) b)))) (inr N (bytes))) (d...
using System; using System.Numerics; using System.Text; class Program { static void Main(string[] args) { BigInteger n = BigInteger.Parse("9516311845790656153499716760847001433441357"); BigInteger e = 65537; BigInteger d = BigInteger.Parse("5617843187844953170308463622230283376298685");...
Write the same code in Java as shown below in Racket.
#lang racket (require math/number-theory) (define-logger rsa) (current-logger rsa-logger) (define (bytes->number B) (for/fold ((rv 0)) ((b B)) (+ b (* rv 256)))) (define (number->bytes N) (define (inr n b) (if (zero? n) b (inr (quotient n 256) (bytes-append (bytes (modulo n 256)) b)))) (inr N (bytes))) (d...
public static void main(String[] args) { BigInteger n = new BigInteger("9516311845790656153499716760847001433441357"); BigInteger e = new BigInteger("65537"); BigInteger d = new BigInteger("5617843187844953170308463622230283376298685"); Charset c = Charsets.UTF_8; String plainText = "Rosetta Co...
Preserve the algorithm and functionality while converting the code from Racket to Python.
#lang racket (require math/number-theory) (define-logger rsa) (current-logger rsa-logger) (define (bytes->number B) (for/fold ((rv 0)) ((b B)) (+ b (* rv 256)))) (define (number->bytes N) (define (inr n b) (if (zero? n) b (inr (quotient n 256) (bytes-append (bytes (modulo n 256)) b)))) (inr N (bytes))) (d...
import binascii n = 9516311845790656153499716760847001433441357 e = 65537 d = 5617843187844953170308463622230283376298685 message='Rosetta Code!' print('message ', message) hex_data = binascii.hexlify(message.encode()) print('hex data ', hex_data) plain_text = int(hex_data, 16) ...
Generate a VB translation of this Racket snippet without changing its computational steps.
#lang racket (require math/number-theory) (define-logger rsa) (current-logger rsa-logger) (define (bytes->number B) (for/fold ((rv 0)) ((b B)) (+ b (* rv 256)))) (define (number->bytes N) (define (inr n b) (if (zero? n) b (inr (quotient n 256) (bytes-append (bytes (modulo n 256)) b)))) (inr N (bytes))) (d...
Imports System Imports System.Numerics Imports System.Text Module Module1 Sub Main() Dim n As BigInteger = BigInteger.Parse("9516311845790656153499716760847001433441357") Dim e As BigInteger = 65537 Dim d As BigInteger = BigInteger.Parse("5617843187844953170308463622230283376298685") ...
Rewrite the snippet below in Go so it works the same as the original Racket code.
#lang racket (require math/number-theory) (define-logger rsa) (current-logger rsa-logger) (define (bytes->number B) (for/fold ((rv 0)) ((b B)) (+ b (* rv 256)))) (define (number->bytes N) (define (inr n b) (if (zero? n) b (inr (quotient n 256) (bytes-append (bytes (modulo n 256)) b)))) (inr N (bytes))) (d...
package main import ( "fmt" "math/big" ) func main() { var n, e, d, bb, ptn, etn, dtn big.Int pt := "Rosetta Code" fmt.Println("Plain text: ", pt) n.SetString("9516311845790656153499716760847001433441357", 10) e.SetString("65537", 10) d.SetString("56178431878...
Transform the following Ruby implementation into C, maintaining the same output and logic.
require 'openssl' require 'prime' def rsa_encode blocks, e, n blocks.map{|b| b.to_bn.mod_exp(e, n).to_i} end def rsa_decode ciphers, d, n rsa_encode ciphers, d, n end def text_to_blocks text, blocksize=64 text.each_byte.reduce(""){|acc,b| acc << b.to_s(16).rjust(2, "0")} .each_char.each_slice(bloc...
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <gmp.h> int main(void) { mpz_t n, d, e, pt, ct; mpz_init(pt); mpz_init(ct); mpz_init_set_str(n, "9516311845790656153499716760847001433441357", 10); mpz_init_set_str(e, "65537", 10); mpz_init_set_str(d, "56178431878449531703084...
Convert this Ruby block to C#, preserving its control flow and logic.
require 'openssl' require 'prime' def rsa_encode blocks, e, n blocks.map{|b| b.to_bn.mod_exp(e, n).to_i} end def rsa_decode ciphers, d, n rsa_encode ciphers, d, n end def text_to_blocks text, blocksize=64 text.each_byte.reduce(""){|acc,b| acc << b.to_s(16).rjust(2, "0")} .each_char.each_slice(bloc...
using System; using System.Numerics; using System.Text; class Program { static void Main(string[] args) { BigInteger n = BigInteger.Parse("9516311845790656153499716760847001433441357"); BigInteger e = 65537; BigInteger d = BigInteger.Parse("5617843187844953170308463622230283376298685");...
Produce a language-to-language conversion: from Ruby to Java, same semantics.
require 'openssl' require 'prime' def rsa_encode blocks, e, n blocks.map{|b| b.to_bn.mod_exp(e, n).to_i} end def rsa_decode ciphers, d, n rsa_encode ciphers, d, n end def text_to_blocks text, blocksize=64 text.each_byte.reduce(""){|acc,b| acc << b.to_s(16).rjust(2, "0")} .each_char.each_slice(bloc...
public static void main(String[] args) { BigInteger n = new BigInteger("9516311845790656153499716760847001433441357"); BigInteger e = new BigInteger("65537"); BigInteger d = new BigInteger("5617843187844953170308463622230283376298685"); Charset c = Charsets.UTF_8; String plainText = "Rosetta Co...
Write the same code in Python as shown below in Ruby.
require 'openssl' require 'prime' def rsa_encode blocks, e, n blocks.map{|b| b.to_bn.mod_exp(e, n).to_i} end def rsa_decode ciphers, d, n rsa_encode ciphers, d, n end def text_to_blocks text, blocksize=64 text.each_byte.reduce(""){|acc,b| acc << b.to_s(16).rjust(2, "0")} .each_char.each_slice(bloc...
import binascii n = 9516311845790656153499716760847001433441357 e = 65537 d = 5617843187844953170308463622230283376298685 message='Rosetta Code!' print('message ', message) hex_data = binascii.hexlify(message.encode()) print('hex data ', hex_data) plain_text = int(hex_data, 16) ...
Ensure the translated VB code behaves exactly like the original Ruby snippet.
require 'openssl' require 'prime' def rsa_encode blocks, e, n blocks.map{|b| b.to_bn.mod_exp(e, n).to_i} end def rsa_decode ciphers, d, n rsa_encode ciphers, d, n end def text_to_blocks text, blocksize=64 text.each_byte.reduce(""){|acc,b| acc << b.to_s(16).rjust(2, "0")} .each_char.each_slice(bloc...
Imports System Imports System.Numerics Imports System.Text Module Module1 Sub Main() Dim n As BigInteger = BigInteger.Parse("9516311845790656153499716760847001433441357") Dim e As BigInteger = 65537 Dim d As BigInteger = BigInteger.Parse("5617843187844953170308463622230283376298685") ...
Ensure the translated Go code behaves exactly like the original Ruby snippet.
require 'openssl' require 'prime' def rsa_encode blocks, e, n blocks.map{|b| b.to_bn.mod_exp(e, n).to_i} end def rsa_decode ciphers, d, n rsa_encode ciphers, d, n end def text_to_blocks text, blocksize=64 text.each_byte.reduce(""){|acc,b| acc << b.to_s(16).rjust(2, "0")} .each_char.each_slice(bloc...
package main import ( "fmt" "math/big" ) func main() { var n, e, d, bb, ptn, etn, dtn big.Int pt := "Rosetta Code" fmt.Println("Plain text: ", pt) n.SetString("9516311845790656153499716760847001433441357", 10) e.SetString("65537", 10) d.SetString("56178431878...
Change the programming language of this snippet from Scala to C without modifying what it does.
import java.math.BigInteger fun main(args: Array<String>) { val n = BigInteger("9516311845790656153499716760847001433441357") val e = BigInteger("65537") val d = BigInteger("5617843187844953170308463622230283376298685") val c = Charsets.UTF_8 val plainText = "Rosetta Code" println("PlainText ...
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <gmp.h> int main(void) { mpz_t n, d, e, pt, ct; mpz_init(pt); mpz_init(ct); mpz_init_set_str(n, "9516311845790656153499716760847001433441357", 10); mpz_init_set_str(e, "65537", 10); mpz_init_set_str(d, "56178431878449531703084...
Can you help me rewrite this code in C# instead of Scala, keeping it the same logically?
import java.math.BigInteger fun main(args: Array<String>) { val n = BigInteger("9516311845790656153499716760847001433441357") val e = BigInteger("65537") val d = BigInteger("5617843187844953170308463622230283376298685") val c = Charsets.UTF_8 val plainText = "Rosetta Code" println("PlainText ...
using System; using System.Numerics; using System.Text; class Program { static void Main(string[] args) { BigInteger n = BigInteger.Parse("9516311845790656153499716760847001433441357"); BigInteger e = 65537; BigInteger d = BigInteger.Parse("5617843187844953170308463622230283376298685");...
Generate a Java translation of this Scala snippet without changing its computational steps.
import java.math.BigInteger fun main(args: Array<String>) { val n = BigInteger("9516311845790656153499716760847001433441357") val e = BigInteger("65537") val d = BigInteger("5617843187844953170308463622230283376298685") val c = Charsets.UTF_8 val plainText = "Rosetta Code" println("PlainText ...
public static void main(String[] args) { BigInteger n = new BigInteger("9516311845790656153499716760847001433441357"); BigInteger e = new BigInteger("65537"); BigInteger d = new BigInteger("5617843187844953170308463622230283376298685"); Charset c = Charsets.UTF_8; String plainText = "Rosetta Co...
Please provide an equivalent version of this Scala code in Python.
import java.math.BigInteger fun main(args: Array<String>) { val n = BigInteger("9516311845790656153499716760847001433441357") val e = BigInteger("65537") val d = BigInteger("5617843187844953170308463622230283376298685") val c = Charsets.UTF_8 val plainText = "Rosetta Code" println("PlainText ...
import binascii n = 9516311845790656153499716760847001433441357 e = 65537 d = 5617843187844953170308463622230283376298685 message='Rosetta Code!' print('message ', message) hex_data = binascii.hexlify(message.encode()) print('hex data ', hex_data) plain_text = int(hex_data, 16) ...
Translate the given Scala code snippet into VB without altering its behavior.
import java.math.BigInteger fun main(args: Array<String>) { val n = BigInteger("9516311845790656153499716760847001433441357") val e = BigInteger("65537") val d = BigInteger("5617843187844953170308463622230283376298685") val c = Charsets.UTF_8 val plainText = "Rosetta Code" println("PlainText ...
Imports System Imports System.Numerics Imports System.Text Module Module1 Sub Main() Dim n As BigInteger = BigInteger.Parse("9516311845790656153499716760847001433441357") Dim e As BigInteger = 65537 Dim d As BigInteger = BigInteger.Parse("5617843187844953170308463622230283376298685") ...
Rewrite this program in Go while keeping its functionality equivalent to the Scala version.
import java.math.BigInteger fun main(args: Array<String>) { val n = BigInteger("9516311845790656153499716760847001433441357") val e = BigInteger("65537") val d = BigInteger("5617843187844953170308463622230283376298685") val c = Charsets.UTF_8 val plainText = "Rosetta Code" println("PlainText ...
package main import ( "fmt" "math/big" ) func main() { var n, e, d, bb, ptn, etn, dtn big.Int pt := "Rosetta Code" fmt.Println("Plain text: ", pt) n.SetString("9516311845790656153499716760847001433441357", 10) e.SetString("65537", 10) d.SetString("56178431878...
Change the following Tcl code into C without altering its purpose.
package require Tcl 8.5 proc modexp {b expAndMod} { lassign $expAndMod -> e n if {$b >= $n} {puts stderr "WARNING: modulus too small"} for {set r 1} {$e != 0} {set e [expr {$e >> 1}]} { if {$e & 1} { set r [expr {($r * $b) % $n}] } set b [expr {($b ** 2) % $n}] } return $r } proc rsa_en...
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <gmp.h> int main(void) { mpz_t n, d, e, pt, ct; mpz_init(pt); mpz_init(ct); mpz_init_set_str(n, "9516311845790656153499716760847001433441357", 10); mpz_init_set_str(e, "65537", 10); mpz_init_set_str(d, "56178431878449531703084...
Can you help me rewrite this code in C# instead of Tcl, keeping it the same logically?
package require Tcl 8.5 proc modexp {b expAndMod} { lassign $expAndMod -> e n if {$b >= $n} {puts stderr "WARNING: modulus too small"} for {set r 1} {$e != 0} {set e [expr {$e >> 1}]} { if {$e & 1} { set r [expr {($r * $b) % $n}] } set b [expr {($b ** 2) % $n}] } return $r } proc rsa_en...
using System; using System.Numerics; using System.Text; class Program { static void Main(string[] args) { BigInteger n = BigInteger.Parse("9516311845790656153499716760847001433441357"); BigInteger e = 65537; BigInteger d = BigInteger.Parse("5617843187844953170308463622230283376298685");...
Rewrite the snippet below in Java so it works the same as the original Tcl code.
package require Tcl 8.5 proc modexp {b expAndMod} { lassign $expAndMod -> e n if {$b >= $n} {puts stderr "WARNING: modulus too small"} for {set r 1} {$e != 0} {set e [expr {$e >> 1}]} { if {$e & 1} { set r [expr {($r * $b) % $n}] } set b [expr {($b ** 2) % $n}] } return $r } proc rsa_en...
public static void main(String[] args) { BigInteger n = new BigInteger("9516311845790656153499716760847001433441357"); BigInteger e = new BigInteger("65537"); BigInteger d = new BigInteger("5617843187844953170308463622230283376298685"); Charset c = Charsets.UTF_8; String plainText = "Rosetta Co...
Keep all operations the same but rewrite the snippet in Python.
package require Tcl 8.5 proc modexp {b expAndMod} { lassign $expAndMod -> e n if {$b >= $n} {puts stderr "WARNING: modulus too small"} for {set r 1} {$e != 0} {set e [expr {$e >> 1}]} { if {$e & 1} { set r [expr {($r * $b) % $n}] } set b [expr {($b ** 2) % $n}] } return $r } proc rsa_en...
import binascii n = 9516311845790656153499716760847001433441357 e = 65537 d = 5617843187844953170308463622230283376298685 message='Rosetta Code!' print('message ', message) hex_data = binascii.hexlify(message.encode()) print('hex data ', hex_data) plain_text = int(hex_data, 16) ...
Rewrite the snippet below in VB so it works the same as the original Tcl code.
package require Tcl 8.5 proc modexp {b expAndMod} { lassign $expAndMod -> e n if {$b >= $n} {puts stderr "WARNING: modulus too small"} for {set r 1} {$e != 0} {set e [expr {$e >> 1}]} { if {$e & 1} { set r [expr {($r * $b) % $n}] } set b [expr {($b ** 2) % $n}] } return $r } proc rsa_en...
Imports System Imports System.Numerics Imports System.Text Module Module1 Sub Main() Dim n As BigInteger = BigInteger.Parse("9516311845790656153499716760847001433441357") Dim e As BigInteger = 65537 Dim d As BigInteger = BigInteger.Parse("5617843187844953170308463622230283376298685") ...
Port the following code from Tcl to Go with equivalent syntax and logic.
package require Tcl 8.5 proc modexp {b expAndMod} { lassign $expAndMod -> e n if {$b >= $n} {puts stderr "WARNING: modulus too small"} for {set r 1} {$e != 0} {set e [expr {$e >> 1}]} { if {$e & 1} { set r [expr {($r * $b) % $n}] } set b [expr {($b ** 2) % $n}] } return $r } proc rsa_en...
package main import ( "fmt" "math/big" ) func main() { var n, e, d, bb, ptn, etn, dtn big.Int pt := "Rosetta Code" fmt.Println("Plain text: ", pt) n.SetString("9516311845790656153499716760847001433441357", 10) e.SetString("65537", 10) d.SetString("56178431878...
Produce a language-to-language conversion: from C to Rust, same semantics.
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <gmp.h> int main(void) { mpz_t n, d, e, pt, ct; mpz_init(pt); mpz_init(ct); mpz_init_set_str(n, "9516311845790656153499716760847001433441357", 10); mpz_init_set_str(e, "65537", 10); mpz_init_set_str(d, "56178431878449531703084...
extern crate num; use num::bigint::BigUint; use num::integer::Integer; use num::traits::{One, Zero}; fn mod_exp(b: &BigUint, e: &BigUint, n: &BigUint) -> Result<BigUint, &'static str> { if n.is_zero() { return Err("modulus is zero"); } if b >= n { return Err("base is >= modulus");...
Change the following C# code into Rust without altering its purpose.
using System; using System.Numerics; using System.Text; class Program { static void Main(string[] args) { BigInteger n = BigInteger.Parse("9516311845790656153499716760847001433441357"); BigInteger e = 65537; BigInteger d = BigInteger.Parse("5617843187844953170308463622230283376298685");...
extern crate num; use num::bigint::BigUint; use num::integer::Integer; use num::traits::{One, Zero}; fn mod_exp(b: &BigUint, e: &BigUint, n: &BigUint) -> Result<BigUint, &'static str> { if n.is_zero() { return Err("modulus is zero"); } if b >= n { return Err("base is >= modulus");...
Write the same algorithm in Rust as shown in this Java implementation.
public static void main(String[] args) { BigInteger n = new BigInteger("9516311845790656153499716760847001433441357"); BigInteger e = new BigInteger("65537"); BigInteger d = new BigInteger("5617843187844953170308463622230283376298685"); Charset c = Charsets.UTF_8; String plainText = "Rosetta Co...
extern crate num; use num::bigint::BigUint; use num::integer::Integer; use num::traits::{One, Zero}; fn mod_exp(b: &BigUint, e: &BigUint, n: &BigUint) -> Result<BigUint, &'static str> { if n.is_zero() { return Err("modulus is zero"); } if b >= n { return Err("base is >= modulus");...
Can you help me rewrite this code in Python instead of Rust, keeping it the same logically?
extern crate num; use num::bigint::BigUint; use num::integer::Integer; use num::traits::{One, Zero}; fn mod_exp(b: &BigUint, e: &BigUint, n: &BigUint) -> Result<BigUint, &'static str> { if n.is_zero() { return Err("modulus is zero"); } if b >= n { return Err("base is >= modulus");...
import binascii n = 9516311845790656153499716760847001433441357 e = 65537 d = 5617843187844953170308463622230283376298685 message='Rosetta Code!' print('message ', message) hex_data = binascii.hexlify(message.encode()) print('hex data ', hex_data) plain_text = int(hex_data, 16) ...
Rewrite this program in VB while keeping its functionality equivalent to the Rust version.
extern crate num; use num::bigint::BigUint; use num::integer::Integer; use num::traits::{One, Zero}; fn mod_exp(b: &BigUint, e: &BigUint, n: &BigUint) -> Result<BigUint, &'static str> { if n.is_zero() { return Err("modulus is zero"); } if b >= n { return Err("base is >= modulus");...
Imports System Imports System.Numerics Imports System.Text Module Module1 Sub Main() Dim n As BigInteger = BigInteger.Parse("9516311845790656153499716760847001433441357") Dim e As BigInteger = 65537 Dim d As BigInteger = BigInteger.Parse("5617843187844953170308463622230283376298685") ...
Change the programming language of this snippet from Go to Rust without modifying what it does.
package main import ( "fmt" "math/big" ) func main() { var n, e, d, bb, ptn, etn, dtn big.Int pt := "Rosetta Code" fmt.Println("Plain text: ", pt) n.SetString("9516311845790656153499716760847001433441357", 10) e.SetString("65537", 10) d.SetString("56178431878...
extern crate num; use num::bigint::BigUint; use num::integer::Integer; use num::traits::{One, Zero}; fn mod_exp(b: &BigUint, e: &BigUint, n: &BigUint) -> Result<BigUint, &'static str> { if n.is_zero() { return Err("modulus is zero"); } if b >= n { return Err("base is >= modulus");...
Maintain the same structure and functionality when rewriting this code in C#.
WITH Ada.Containers.Generic_Array_Sort, Ada.Text_IO; USE Ada.Text_IO; PROCEDURE Main IS TYPE Natural_Array IS ARRAY (Positive RANGE <>) OF Natural; FUNCTION Less (L, R : Natural) RETURN Boolean IS (L'Img < R'Img); PROCEDURE Sort_Naturals IS NEW Ada.Containers.Generic_Array_Sort (Positive, Natural, Natura...
using static System.Console; using static System.Linq.Enumerable; public class Program { public static void Main() { foreach (int n in new [] { 0, 5, 13, 21, -22 }) WriteLine($"{n}: {string.Join(", ", LexOrder(n))}"); } public static IEnumerable<int> LexOrder(int n) => (n < 1 ? Range(n, 2 - n) : R...
Generate a C translation of this Ada snippet without changing its computational steps.
WITH Ada.Containers.Generic_Array_Sort, Ada.Text_IO; USE Ada.Text_IO; PROCEDURE Main IS TYPE Natural_Array IS ARRAY (Positive RANGE <>) OF Natural; FUNCTION Less (L, R : Natural) RETURN Boolean IS (L'Img < R'Img); PROCEDURE Sort_Naturals IS NEW Ada.Containers.Generic_Array_Sort (Positive, Natural, Natura...
#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> int compareStrings(const void *a, const void *b) { const char **aa = (const char **)a; const char **bb = (const char **)b; return strcmp(*aa, *bb); } void lexOrder(int n, int *ints) { char **strs; int i, first = 1, last =...
Convert this Ada block to C++, preserving its control flow and logic.
WITH Ada.Containers.Generic_Array_Sort, Ada.Text_IO; USE Ada.Text_IO; PROCEDURE Main IS TYPE Natural_Array IS ARRAY (Positive RANGE <>) OF Natural; FUNCTION Less (L, R : Natural) RETURN Boolean IS (L'Img < R'Img); PROCEDURE Sort_Naturals IS NEW Ada.Containers.Generic_Array_Sort (Positive, Natural, Natura...
#include <algorithm> #include <iostream> #include <numeric> #include <string> #include <vector> void lexicographical_sort(std::vector<int>& numbers) { std::vector<std::string> strings(numbers.size()); std::transform(numbers.begin(), numbers.end(), strings.begin(), [](int i) { return std::to_...
Change the following Ada code into Go without altering its purpose.
WITH Ada.Containers.Generic_Array_Sort, Ada.Text_IO; USE Ada.Text_IO; PROCEDURE Main IS TYPE Natural_Array IS ARRAY (Positive RANGE <>) OF Natural; FUNCTION Less (L, R : Natural) RETURN Boolean IS (L'Img < R'Img); PROCEDURE Sort_Naturals IS NEW Ada.Containers.Generic_Array_Sort (Positive, Natural, Natura...
package main import ( "fmt" "sort" "strconv" ) func lexOrder(n int) []int { first, last, k := 1, n, n if n < 1 { first, last, k = n, 1, 2-n } strs := make([]string, k) for i := first; i <= last; i++ { strs[i-first] = strconv.Itoa(i) } sort.Strings(strs) ints...
Convert the following code from Ada to Java, ensuring the logic remains intact.
WITH Ada.Containers.Generic_Array_Sort, Ada.Text_IO; USE Ada.Text_IO; PROCEDURE Main IS TYPE Natural_Array IS ARRAY (Positive RANGE <>) OF Natural; FUNCTION Less (L, R : Natural) RETURN Boolean IS (L'Img < R'Img); PROCEDURE Sort_Naturals IS NEW Ada.Containers.Generic_Array_Sort (Positive, Natural, Natura...
import java.util.List; import java.util.stream.*; public class LexicographicalNumbers { static List<Integer> lexOrder(int n) { int first = 1, last = n; if (n < 1) { first = n; last = 1; } return IntStream.rangeClosed(first, last) .map...
Ensure the translated Python code behaves exactly like the original Ada snippet.
WITH Ada.Containers.Generic_Array_Sort, Ada.Text_IO; USE Ada.Text_IO; PROCEDURE Main IS TYPE Natural_Array IS ARRAY (Positive RANGE <>) OF Natural; FUNCTION Less (L, R : Natural) RETURN Boolean IS (L'Img < R'Img); PROCEDURE Sort_Naturals IS NEW Ada.Containers.Generic_Array_Sort (Positive, Natural, Natura...
n=13 print(sorted(range(1,n+1), key=str))