-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
53 lines (44 loc) · 2.06 KB
/
main.go
File metadata and controls
53 lines (44 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package main
import (
"RsaEx/util"
"fmt"
)
var (
bigContentNotForRsa = `TOP 10 FACTS ABOUT SHAKESPEARE!
Trivia Fact 1 - No one knows the actual birthday of Shakespeare!
Trivia Fact 2 - Anne Hathaway was eight years older than Shakespeare and three months pregnant when they got married!
Trivia Fact 3 - Many Shakespeare life facts are unknown - these are referred to as the Lost Years
Trivia Fact 4 - Shakespeare's Father, John was a money lender! He was accused in the Exchequer Court of Usury for lending money at the inflated rate of 20% and 25% Interest!
Trivia Fact 5 - William Arden, a relative of Shakespeare's mother Mary Arden, was arrested for plotting against Queen Elizabeth I, imprisoned in the Tower of London and executed!
Trivia Fact 6 - Shakespeare and his company built TWO Globe Theatres!
Trivia Fact 7 - Shakespeare never published any of his plays!
Trivia Fact 8 - Shakespeare and the Globe Actors were implicated in the Essex Rebellion of 1601!
Trivia Fact 9 - Many eminent Authors and Politicians do not believe that Shakespeare wrote his plays...
Trivia Fact 10 - Shakespeare's family were all illiterate!`
myKey string
myPublicKey string
hisKey string
hisPublicKey string
myPassphrase = "secret123~"
hisPassphrase = "sddfdfba!Q"
)
func init() {
myKey, myPublicKey = util.NewKeys(myPassphrase)
hisKey, hisPublicKey = util.NewKeys(hisPassphrase)
}
func main() {
//I do
sessionKey, _ := util.GenerateRandomString(32)
encryptedContent := util.EncryptPlainBF(bigContentNotForRsa, sessionKey)
encryptedSessionKey, keySignature := util.EncryptAndSignRsa(sessionKey, hisPublicKey, myKey, myPassphrase)
//send encryptedContent, encryptedSessionKey, keySignature
//he does
decryptedSessionKey, verified := util.DecryptAndVerifyRsa(encryptedSessionKey, keySignature, hisKey, myPublicKey, hisPassphrase)
if verified {
fmt.Println("Session key is verified")
decryptedContent := util.DecryptPlainBF(encryptedContent, decryptedSessionKey)
fmt.Println("Decrypted:", decryptedContent)
} else {
fmt.Println("Session key is NOT verified!")
}
}