-
Notifications
You must be signed in to change notification settings - Fork 5
/
setemailhash.html
109 lines (89 loc) · 2.76 KB
/
setemailhash.html
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Set e-mail hash</title>
<script src="http://cdn.jsdelivr.net/ripple/0.7.30/ripple-lib-min.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/md5.js"></script>
<script>
// Loading ripple-lib in a webpage
var Remote = ripple.Remote;
var Seed = ripple.Seed;
var remote = new Remote({
// see the API Reference for available options
trusted: false,
local_signing: true,
local_fee: true,
fee_cushion: 1.5,
max_fee: 50,
servers: [
{
host: 's1.ripple.com'
, port: 443
, secure: true
}
]
});
function output(inp) {
document.body.appendChild(document.createElement('pre')).innerHTML = inp;
}
window.onload = function() {
var submitbutton = document.getElementById('submitbutton');
submitbutton.onclick = function() {submittoserver();};
}
function submittoserver() {
var email = document.getElementById('emailaddress').value;
email = email.trim();
email = email.toLowerCase();
var hash = "00000000000000000000000000000000";
if (email !== "") {
hash = CryptoJS.MD5(email).toString();
hash = hash.toUpperCase();
}
var MY_ADDRESS = document.getElementById('accountaddress').value;
MY_ADDRESS = MY_ADDRESS.trim();
var MY_SECRET = document.getElementById('accountsecret').value;
MY_SECRET = MY_SECRET.trim();
remote.connect(function() {
// remote connected
// see the API Reference for available functions
var str;
if (!Seed.from_json(MY_SECRET).is_valid()) {
output("Error: Secret invalid");
}
remote.set_secret(MY_ADDRESS, MY_SECRET);
var transaction = remote.transaction();
try {
transaction.account_set(MY_ADDRESS);
} catch (error) {
output(error);
}
transaction.tx_json.EmailHash = hash;
transaction.submit(function(err, res) {
if (err) {
str = JSON.stringify(err, undefined, 2);
}
if (res) {
str = JSON.stringify(res, undefined, 2);
}
output(str);
remote.disconnect();
});
});
}
</script>
</head>
<body>
<h1>Set e-mail hash</h1>
Account address:
<input id="accountaddress" type=text
value="rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh" size=40><br>
Account secret:
<input id="accountsecret" type=text
value="snoPBrXtMeMyMHUVTgbuqAfg1SUTb" size=40><br>
E-mail address:
<input id="emailaddress" type=text
value="user@example.com" size=40><br>
<button id="submitbutton">Submit</button>
</body>
</html>