THE FORUM IS IN READ-ONLY MODE

This forum is in read-only mode. The new forum is live at https://discourse.openbullet.dev and registrations are open!

Translate GO language for RSA Encryption



  • Hello, I am trying to use OB to encrypt a string with RSA encryption from a GO code but I can't seem to figure out how.

    Here is the code

    package main
    
    import (
    	"crypto/rand"
    	"crypto/rsa"
    	"encoding/base64"
    	"log"
    	"math/big"
    )
    
    var publicKey rsa.PublicKey
    
    // Default encryption key in hex.
    const keyInHex string = "c3bde91d3cc1cddc06219bfbe4b494fe609afb708e4372c34aa9db31e43657d200ee585b888f377006eb6b2183cd9912751bcc9b0c817ba035b6784a66e6c31b2fdcecf44c5709dbeaae7e75a842dbaa3d17c6d3132296821c5488e743df3e94c557d5edfe19b2570a24a0e5c59401200a7f900a01ace766c5a1832dca2fb111"
    
    func init() {
    	publicKey.N, _ = new(big.Int).SetString(keyInHex, 16)
    	publicKey.E = 65537
    }
    
    func encryptPassword(password []byte) string {
    	// Password encryption with RSA 1024 Bit key and PKCS1v15 padding
    	encrypted, err := rsa.EncryptPKCS1v15(rand.Reader, &publicKey, password)
    	if err != nil {
    		log.Panic(err)
    	}
    	return base64.StdEncoding.EncodeToString(encrypted)
    }
    

    Thank you.



  • I guess that you'll have to extract the keys yourself, and use them in the function block with RSA



  • @RandomFag
    show some results example from your GO code and let see if I could replicate it in OB



  • @Fairy Yes, thats the main issue here



  • @Br4uN It is not my code, I found it, and I really dont know how to compile/use GO



  • @RandomFag To compile you can use the site: https://repl.it/languages/go
    KQKeWMQjFz_32860.png

    INF:

    • Key: c3bde91d3cc1cddc06219bfbe4b494fe609afb708e4372c34aa9db31e43657d200ee585b888f377006eb6b2183cd9912751bcc9b0c817ba035b6784a66e6c31b2fdcecf44c5709dbeaae7e75a842dbaa3d17c6d3132296821c5488e743df3e94c557d5edfe19b2570a24a0e5c59401200a7f900a01ace766c5a1832dca2fb111
    • Expo: 65537
    • Input: My secret payload : D

Log in to reply