encpassword

package module
v0.0.0-...-0ecf29c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2023 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package encpassword implements the password encryption used by Instagram, the encryption is a hybrid encryption, using public-key encryption to encrypt the symmetric key used for encrypting the password.

The public-key encryption is done using NaCl's sealed box, which is based on XSalsa20, Poly1305 and Blake2b. The symmetric encryption is done using AES-256 in GCM mode. You should generate a random key and encrypt the message with that key and zero nonce.

The result of both encryption's is then encoded using base64, which also contains information about the current version and id of the public key used.

Index

Constants

View Source
const (
	// CurrentVersion is the current version of the password encryption.
	CurrentVersion = "10"
)

Variables

This section is empty.

Functions

func EncryptPassword

func EncryptPassword(pk *PublicKey, password string) (string, error)

EncryptPassword encrypts the given password using the given public key.

func EncryptPasswordCustom

func EncryptPasswordCustom(pk *PublicKey, password string, time int64, random io.Reader) (string, error)

EncryptPasswordCustom encrypts the given password using the given public key, that allows to provide custom time and random source.

Types

type PublicKey

type PublicKey struct {
	// contains filtered or unexported fields
}

PublicKey represents a public key used for encrypting passwords. You can get the public key from the Instagram web app.

func NewPublicKey

func NewPublicKey(id, key string) (*PublicKey, error)

NewPublicKey creates a new public key from the given id, version and key.

func NewPublicKeyCustom

func NewPublicKeyCustom(id, version, key string) (*PublicKey, error)

NewPublicKeyCustom creates a new public key from the given id, version and key. Note, version is not checked, and may be invalid or not supported.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL