chore: reorg
This commit is contained in:
1475
actix-web/Cargo.lock
generated
1475
actix-web/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -1,12 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "actix-web"
|
|
||||||
version = "0.1.0"
|
|
||||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
|
||||||
edition = "2018"
|
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
actix-web = "2"
|
|
||||||
actix-rt = "1"
|
|
||||||
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
use actix_web::{
|
|
||||||
get, web, App, HttpServer, Responder, HttpRequest, HttpResponse,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[get("/{id}/{name}/index.html")]
|
|
||||||
async fn index(info: web::Path<(u32, String)>) -> impl Responder {
|
|
||||||
format!("Hello {}! id:{}", info.1, info.0)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[get("/name")]
|
|
||||||
async fn index_name() -> impl Responder {
|
|
||||||
format!("Hello name!\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn index2(req: HttpRequest) -> HttpResponse {
|
|
||||||
println!("{:?}", req);
|
|
||||||
HttpResponse::Ok()
|
|
||||||
.content_type("text/plain")
|
|
||||||
.body("Welcome!\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
#[actix_rt::main]
|
|
||||||
async fn main() -> std::io::Result<()> {
|
|
||||||
println!("Listen at: http://127.0.0.1:8080/");
|
|
||||||
|
|
||||||
HttpServer::new(|| App::new()
|
|
||||||
.service(index)
|
|
||||||
.service(index_name)
|
|
||||||
.service(web::resource("/").to(index2))
|
|
||||||
)
|
|
||||||
.bind("127.0.0.1:8080")?
|
|
||||||
.run()
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
1865
actix_rustls/Cargo.lock
generated
1865
actix_rustls/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -1,12 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "actix_rustls"
|
|
||||||
version = "0.1.0"
|
|
||||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
|
||||||
edition = "2018"
|
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
rustls = "0.18"
|
|
||||||
actix-web = { version = "3.1", features = ["rustls"] }
|
|
||||||
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
https://www.mdeditor.tw/pl/pVR6
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
-----BEGIN CERTIFICATE-----
|
|
||||||
MIIEczCCAtugAwIBAgIVANtxEITBMdlrkDCaLZGYyxlH2g7eMA0GCSqGSIb3DQEB
|
|
||||||
CwUAMCYxJDAiBgNVBAMMG0hhdHRlciBUZXN0IEludGVybWVkaWF0ZSBDQTAeFw0x
|
|
||||||
OTA2MDMwMDAwMDBaFw0yNDA2MDMwMDAwMDBaMBYxFDASBgNVBAMMC2V4YW1wbGUu
|
|
||||||
Y29tMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA3sFqqYgsr6taCt5x
|
|
||||||
fJ0esQUo5TfvHaGMwiKqp8Wz5Z2qkEWgGyk7TLAzFdh74kgK42GT7ajz2BOuGjOG
|
|
||||||
h23UJIsvCM6CPH0P/e9NwPAkwst7XRUvwKC1l0952E6eVPi68CQ5JNrpcwD9Gwz9
|
|
||||||
74lBc/LhmEgpczTedSzo1PP+yl5+kvtj7HQ+D42t119UIQk08w6yyg65X/m9YDXy
|
|
||||||
aqEF/nEGTW/p9UCjyUPMNENcXxdkqb4U4GZP7Y8AnxOR43IitKDJiAcRN7I5NzOR
|
|
||||||
OACa28fb12rDWEDaNV2pfIkxWRSpgrIqB6D4fkCoFO5k6VuRZozaA41HWaxpSfYn
|
|
||||||
2fc5WiAGnW1KU5kRQwtLBefWBiMWzhxQjC7g0ZN1RLDIK8bU6PgPRbncuMXtMe+n
|
|
||||||
3M62uBihmP+yE590W3UZ3Fe7kmp6F0bgelp7m1RgkXv46NCF46TUoMtjerrvtPIe
|
|
||||||
cV3lziYcfGd8xh8+isFOJnYiqz2XdhRLAaqUMdIcKECDzSWDAgMBAAGjgacwgaQw
|
|
||||||
DgYDVR0PAQH/BAQDAgWgMAwGA1UdEwEB/wQCMAAwHQYDVR0lBBYwFAYIKwYBBQUH
|
|
||||||
AwEGCCsGAQUFBwMCMCUGA1UdEQQeMByCC2V4YW1wbGUuY29tgg0qLmV4YW1wbGUu
|
|
||||||
Y29tMB0GA1UdDgQWBBTxqz0CCK+umU+67N0RAInTy3CFlzAfBgNVHSMEGDAWgBT/
|
|
||||||
l70lphw5HEmXYdRc1xhwNNfLSDANBgkqhkiG9w0BAQsFAAOCAYEAd2Gz9l+5RT4Y
|
|
||||||
AozhgD/KFsi0dTkoJ20Tnw0LfRi3ig1mJFF4qQ2/hMm0Xy0kro9xTZHSblWukbDi
|
|
||||||
pbRuIPvNhLgHt55w0lDJTgsC2dEBi5SMgWABYY98QbcKhoy9s9T1uxvdUUxo55Bw
|
|
||||||
whWbg3hYRmNqkk5FY7HxahfsL6K6b/zjAlGTc3mne0kYTRhjZ2BolO3jpCT0bxFg
|
|
||||||
k6KBNymQLsX1RnP0wbN+Tr09VA/f1vOVU2D/gIyomdLRXS5BRyLfclI/tfJ2q9b8
|
|
||||||
9rLhoKi9xlvVK6XhLMqr9dGTuwNH7YtIzMI0a67UgBRLZnD397jR0YsPeynBuv25
|
|
||||||
bGOMRw8EuSGqL6ZvoLPUVi6Rrx+I+eJRwcQBZ3QjGQkac84OGs1b050cTJyUPkmw
|
|
||||||
87Ymd/effG8mxxBlk3Aogv+xqEDgGbYtgW5ihqk8OsTNzeA07lNdPc35XMoukIRR
|
|
||||||
LUA5YPfbZkwT8riGCKY/mAa1twGcF5hXa4BIw8CJaVFSfrYhgnvf
|
|
||||||
-----END CERTIFICATE-----
|
|
||||||
-----BEGIN CERTIFICATE-----
|
|
||||||
MIIEuTCCAqGgAwIBAgIVAIsCKxneJOj/cG10MuQwOn8uYdUdMA0GCSqGSIb3DQEB
|
|
||||||
CwUAMB4xHDAaBgNVBAMME0hhdHRlciBUZXN0IENBIFJvb3QwHhcNMTkwNjAzMDAw
|
|
||||||
MDAwWhcNMzkwNjAzMDAwMDAwWjAmMSQwIgYDVQQDDBtIYXR0ZXIgVGVzdCBJbnRl
|
|
||||||
cm1lZGlhdGUgQ0EwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQCRkidw
|
|
||||||
HPZYiuLGFV1KNbYB4mp1OoGwYL2MVS0uEMlODF1dRGVTpoF/9bSOvQ7CIxuqbEPF
|
|
||||||
qDu37rZnJ7ixTMnLcnfifek5q+0IdWyYgYyuBiVpgvhW1SzI/RHcZzQImhUkQ6ue
|
|
||||||
ciQCgF2G4ToqZoAnIzImklOhfT3UQXqHQHyra2fW7C1GKq2guUmcjcGwOv5+wy7D
|
|
||||||
SwKqULMXfKNyg1xVdanaU+9DpPGHrbndAjS4XNWLaPSFx05vJU9XmNwkx/1FZn2r
|
|
||||||
r4/geJDZqRwru+rWxrQnQr4sClJcORBT9KeJ94EF3APfpR3GfSYFnUmvcW+NB+qn
|
|
||||||
mpC6Qgy7xiMZuDRo9J1To/uNiPq2i6HBA2HqMlNArznk2eHijmRtwP1mhbVyeFeS
|
|
||||||
kom7gqz+iMTt/ZKiQh1x+2l6IYekGswfqi++1165g74IMn0JSZJY08vX+CGRaVQP
|
|
||||||
yjud4dWh0BJYS/e5hpXEgNdft4KGiGm1eKaKkacWOC+LIjAHlS+OnExbRgkCAwEA
|
|
||||||
AaNmMGQwDgYDVR0PAQH/BAQDAgEGMBIGA1UdEwEB/wQIMAYBAf8CAQAwHQYDVR0O
|
|
||||||
BBYEFP+XvSWmHDkcSZdh1FzXGHA018tIMB8GA1UdIwQYMBaAFG7h4b7D6YJr322D
|
|
||||||
nnS7D+VyBXA8MA0GCSqGSIb3DQEBCwUAA4ICAQAmSn6nelezJsSgu/i7GYlWkluE
|
|
||||||
pSvmtxeL6hvvXf1tKcSGUmwWi+gI8V5/G7cJ/5i9+np7aijFvdXIhVvBS3+Ydg2u
|
|
||||||
7juF/4nD40ZAwu8imH0HLcG2klfCIb4PWPT3zMY5wTijNmlLf2R8Xi/sjbkcaGrH
|
|
||||||
KS2EQiKR1Wo9Aac7RPCeYHr+BORLJY4zKsMA0RfLIhdDxrrT7YrlQguhHCiWulhs
|
|
||||||
vN4cFHt6IQjq0ijjMYKgjyuEWU+6YdrMMQNL3m74mCmbNOTRbL+PTOXzKphA9qcr
|
|
||||||
/V+vPxMWDjpRc+aj7zpelF2IqQnhH8fs6F0shlz6PJsIitsd5CpuSvTUtOQzreTf
|
|
||||||
NQXGS/FWLq0ylxbbXOtfm0Rtu2hXmlCHdz1jp3BD9nrQNgBFAPJVkocg7CyP5eka
|
|
||||||
ZI635dXcM8LpRc8npivQFaqOelvmJHzKhQVoiHjnoz9IuIZBSLsZ9x3cKtZMPsTS
|
|
||||||
+JZ73rrXhJtRGZm6KCyR9ozqAOlapE1uqMLedNneCl8ZHrFU45zX+8dElBh+7iaD
|
|
||||||
6aQug2chqhqB4HZ34rLimDaIVUNwnBOqon4gJ20KQrMlXBKTeeN0CVKBxJiwEKNA
|
|
||||||
rAb/cv+JFXsLz407+Y1E1bVcwqxH55G6K58ZavcrSApVV+sTvoPqlJxD6JSpgrwN
|
|
||||||
iAEAqVLBzHwqXCfAGA==
|
|
||||||
-----END CERTIFICATE-----
|
|
||||||
-----BEGIN CERTIFICATE-----
|
|
||||||
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
|
|
||||||
-----END CERTIFICATE-----
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
use std::sync::Arc;
|
|
||||||
use rustls::ClientHello;
|
|
||||||
use rustls::NoClientAuth;
|
|
||||||
use rustls::ServerConfig;
|
|
||||||
use rustls::ResolvesServerCert;
|
|
||||||
use rustls::sign;
|
|
||||||
use rustls::sign::CertifiedKey;
|
|
||||||
use rustls::internal::pemfile;
|
|
||||||
use actix_web::App;
|
|
||||||
use actix_web::HttpServer;
|
|
||||||
use actix_web::get;
|
|
||||||
use actix_web::Responder;
|
|
||||||
|
|
||||||
const CERT_CHAIN: &str = include_str!("cert_chain.pem");
|
|
||||||
const PRIVATE_KEY: &str = include_str!("private_key.pem");
|
|
||||||
|
|
||||||
struct ResolvesServerCertImpl;
|
|
||||||
impl ResolvesServerCert for ResolvesServerCertImpl {
|
|
||||||
fn resolve(&self, client_hello: ClientHello) -> Option<CertifiedKey> {
|
|
||||||
println!("Request server name: {:?}", client_hello.server_name());
|
|
||||||
|
|
||||||
let mut cert_chain_bytes = CERT_CHAIN.as_bytes();
|
|
||||||
let mut private_key_bytes = PRIVATE_KEY.as_bytes();
|
|
||||||
|
|
||||||
let cert_chain = pemfile::certs(&mut cert_chain_bytes).unwrap();
|
|
||||||
let mut keys = pemfile::pkcs8_private_keys(&mut private_key_bytes).unwrap();
|
|
||||||
let signing_key = sign::any_supported_type(&keys.remove(0)).unwrap();
|
|
||||||
|
|
||||||
Some(CertifiedKey::new(cert_chain, Arc::new(signing_key)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[get("/")]
|
|
||||||
async fn index() -> impl Responder {
|
|
||||||
format!("Hello world!")
|
|
||||||
}
|
|
||||||
|
|
||||||
#[actix_web::main]
|
|
||||||
async fn main() -> std::io::Result<()> {
|
|
||||||
let mut config = ServerConfig::new(NoClientAuth::new());
|
|
||||||
config.cert_resolver = Arc::new(ResolvesServerCertImpl);
|
|
||||||
|
|
||||||
let listen = "127.0.0.1:8443";
|
|
||||||
println!("Listen at: {}", listen);
|
|
||||||
HttpServer::new(|| App::new().service(index))
|
|
||||||
.bind_rustls(listen, config)?
|
|
||||||
.run()
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
-----BEGIN PRIVATE KEY-----
|
|
||||||
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
|
|
||||||
kk4MNz4BCcE8K3fyQKOF1vU=
|
|
||||||
-----END PRIVATE KEY-----
|
|
||||||
16
c_export/Cargo.lock
generated
16
c_export/Cargo.lock
generated
@@ -1,16 +0,0 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
|
||||||
# It is not intended for manual editing.
|
|
||||||
[[package]]
|
|
||||||
name = "c_export"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "libc"
|
|
||||||
version = "0.2.60"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[metadata]
|
|
||||||
"checksum libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "d44e80633f007889c7eff624b709ab43c92d708caad982295768a7b13ca3b5eb"
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "c_export"
|
|
||||||
version = "0.1.0"
|
|
||||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
|
||||||
edition = "2018"
|
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
name = "stringtools"
|
|
||||||
crate-type = ["dylib"]
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
libc = "0.2.60"
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
|
|
||||||
Rust libray build:
|
|
||||||
```
|
|
||||||
cargo build
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
Python test:
|
|
||||||
```
|
|
||||||
python call_in_python.py
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
C test:
|
|
||||||
```
|
|
||||||
gcc call_in_c.c -L target/debug/ -lstringtools
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
NodeJS test:
|
|
||||||
```
|
|
||||||
npm install ffi
|
|
||||||
node call_in_node.js
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
Reference:
|
|
||||||
http://siciarz.net/24-days-of-rust-calling-rust-from-other-languages/
|
|
||||||
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
#include <stdint.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int32_t count_substrings(const char* value, const char* substr);
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
printf("%d\n", count_substrings("banana", "na"));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
var ffi = require('ffi');
|
|
||||||
|
|
||||||
var stringtools = ffi.Library('target/debug/libstringtools.dylib', {
|
|
||||||
'count_substrings': ['int', ['string', 'string']]
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log(stringtools.count_substrings("banana", "na"));
|
|
||||||
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
import ctypes
|
|
||||||
|
|
||||||
stringtools = ctypes.CDLL("target/debug/libstringtools.dylib")
|
|
||||||
print(stringtools.count_substrings(b"banana", b"na"))
|
|
||||||
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
extern crate libc;
|
|
||||||
|
|
||||||
use std::ffi::CStr;
|
|
||||||
use libc::c_char;
|
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C" fn count_substrings(value: *const c_char, substr: *const c_char) -> i32 {
|
|
||||||
let c_value = unsafe { CStr::from_ptr(value) };
|
|
||||||
let c_substr = unsafe { CStr::from_ptr(substr) };
|
|
||||||
match c_value.to_str() {
|
|
||||||
Ok(value) => match c_substr.to_str() {
|
|
||||||
Ok(substr) => value.match_indices(substr).count() as i32,
|
|
||||||
Err(_) => -1,
|
|
||||||
},
|
|
||||||
Err(_) => -1,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
161
cpp/Cargo.lock
generated
161
cpp/Cargo.lock
generated
@@ -1,161 +0,0 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
|
||||||
# It is not intended for manual editing.
|
|
||||||
[[package]]
|
|
||||||
name = "aho-corasick"
|
|
||||||
version = "0.7.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "743ad5a418686aad3b87fd14c43badd828cf26e214a00f92a384291cf22e1811"
|
|
||||||
dependencies = [
|
|
||||||
"memchr",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "byteorder"
|
|
||||||
version = "1.3.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cc"
|
|
||||||
version = "1.0.50"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cpp"
|
|
||||||
version = "0.5.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d0d94d130fd605c2df503d59a2784d8ecf8326d2311b50c848dff7bc7b1a61bd"
|
|
||||||
dependencies = [
|
|
||||||
"cpp_macros",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cpp_build"
|
|
||||||
version = "0.5.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d7a67671b8ace8c2eeab3f6e00edd0bfab24026208fa5d039808d6b6efe4beb6"
|
|
||||||
dependencies = [
|
|
||||||
"cc",
|
|
||||||
"cpp_common",
|
|
||||||
"lazy_static",
|
|
||||||
"proc-macro2",
|
|
||||||
"regex",
|
|
||||||
"syn",
|
|
||||||
"unicode-xid",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cpp_common"
|
|
||||||
version = "0.5.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "6b827ced56ffc05f4c918858040091d26f4b4176c670270be85538fe58d89923"
|
|
||||||
dependencies = [
|
|
||||||
"lazy_static",
|
|
||||||
"proc-macro2",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cpp_macros"
|
|
||||||
version = "0.5.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a5c116686c51a8e0b0e0ad5e85121be6a26f175d3193e3507e0b2d8bed65190d"
|
|
||||||
dependencies = [
|
|
||||||
"aho-corasick",
|
|
||||||
"byteorder",
|
|
||||||
"cpp_common",
|
|
||||||
"if_rust_version",
|
|
||||||
"lazy_static",
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "if_rust_version"
|
|
||||||
version = "1.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "46dbcb333e86939721589d25a3557e180b52778cb33c7fdfe9e0158ff790d5ec"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "lazy_static"
|
|
||||||
version = "1.4.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "memchr"
|
|
||||||
version = "2.3.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3197e20c7edb283f87c071ddfc7a2cca8f8e0b888c242959846a6fce03c72223"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "proc-macro2"
|
|
||||||
version = "1.0.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3acb317c6ff86a4e579dfa00fc5e6cca91ecbb4e7eb2df0468805b674eb88548"
|
|
||||||
dependencies = [
|
|
||||||
"unicode-xid",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "quote"
|
|
||||||
version = "1.0.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "regex"
|
|
||||||
version = "1.3.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "322cf97724bea3ee221b78fe25ac9c46114ebb51747ad5babd51a2fc6a8235a8"
|
|
||||||
dependencies = [
|
|
||||||
"aho-corasick",
|
|
||||||
"memchr",
|
|
||||||
"regex-syntax",
|
|
||||||
"thread_local",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "regex-syntax"
|
|
||||||
version = "0.6.14"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b28dfe3fe9badec5dbf0a79a9cccad2cfc2ab5484bdb3e44cbd1ae8b3ba2be06"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rust_sample_cpp"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"cpp",
|
|
||||||
"cpp_build",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "syn"
|
|
||||||
version = "1.0.14"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "af6f3550d8dff9ef7dc34d384ac6f107e5d31c8f57d9f28e0081503f547ac8f5"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"unicode-xid",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "thread_local"
|
|
||||||
version = "1.0.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14"
|
|
||||||
dependencies = [
|
|
||||||
"lazy_static",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "unicode-xid"
|
|
||||||
version = "0.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "rust_sample_cpp"
|
|
||||||
version = "0.1.0"
|
|
||||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
|
||||||
edition = "2018"
|
|
||||||
build = "build.rs"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
cpp = "0.5.4"
|
|
||||||
|
|
||||||
[build-dependencies]
|
|
||||||
cpp_build = "0.5.4"
|
|
||||||
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
extern crate cpp_build;
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
cpp_build::build("src/main.rs");
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
#[macro_use]
|
|
||||||
extern crate cpp;
|
|
||||||
|
|
||||||
cpp!{{
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <iostream>
|
|
||||||
}}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
unsafe {
|
|
||||||
cpp!([] {
|
|
||||||
printf("Hello, World!\n");
|
|
||||||
std::cout << "Hello, World2!" << std::endl;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
215
crypto/Cargo.lock
generated
215
crypto/Cargo.lock
generated
@@ -1,215 +0,0 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
|
||||||
# It is not intended for manual editing.
|
|
||||||
[[package]]
|
|
||||||
name = "block-buffer"
|
|
||||||
version = "0.7.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b"
|
|
||||||
dependencies = [
|
|
||||||
"block-padding",
|
|
||||||
"byte-tools",
|
|
||||||
"byteorder",
|
|
||||||
"generic-array",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "block-padding"
|
|
||||||
version = "0.1.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5"
|
|
||||||
dependencies = [
|
|
||||||
"byte-tools",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "byte-tools"
|
|
||||||
version = "0.3.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "byteorder"
|
|
||||||
version = "1.3.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cfg-if"
|
|
||||||
version = "0.1.10"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "crypto"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"digest",
|
|
||||||
"ecdsa",
|
|
||||||
"ed25519",
|
|
||||||
"elliptic-curve",
|
|
||||||
"k256",
|
|
||||||
"p256",
|
|
||||||
"p384",
|
|
||||||
"p521",
|
|
||||||
"sha2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "digest"
|
|
||||||
version = "0.8.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5"
|
|
||||||
dependencies = [
|
|
||||||
"generic-array",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ecdsa"
|
|
||||||
version = "0.5.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "5a7aaf89875554fab12c9d0855d694803a8820b73bfb89cdc96546b6bcab69e4"
|
|
||||||
dependencies = [
|
|
||||||
"elliptic-curve",
|
|
||||||
"generic-array",
|
|
||||||
"sha2",
|
|
||||||
"signature",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ed25519"
|
|
||||||
version = "1.0.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "bf038a7b6fd7ef78ad3348b63f3a17550877b0e28f8d68bcc94894d1412158bc"
|
|
||||||
dependencies = [
|
|
||||||
"signature",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "elliptic-curve"
|
|
||||||
version = "0.3.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "01f69be7d1feb7a7a04f158aaf32c7deaa7604e9bd58145525e536438c4e5096"
|
|
||||||
dependencies = [
|
|
||||||
"generic-array",
|
|
||||||
"getrandom",
|
|
||||||
"subtle",
|
|
||||||
"zeroize",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "fake-simd"
|
|
||||||
version = "0.1.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "generic-array"
|
|
||||||
version = "0.12.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec"
|
|
||||||
dependencies = [
|
|
||||||
"typenum",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "getrandom"
|
|
||||||
version = "0.1.14"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if",
|
|
||||||
"libc",
|
|
||||||
"wasi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "k256"
|
|
||||||
version = "0.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f8a010224d825405c12a840fc269094683abe1282222f46c368318a02fa8876b"
|
|
||||||
dependencies = [
|
|
||||||
"elliptic-curve",
|
|
||||||
"subtle",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "libc"
|
|
||||||
version = "0.2.69"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "99e85c08494b21a9054e7fe1374a732aeadaff3980b6990b94bfd3a70f690005"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "opaque-debug"
|
|
||||||
version = "0.2.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "p256"
|
|
||||||
version = "0.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "86640e33ca638ec215c74de317696bbca5daa7d52cf55b905bd20a6bd2cfd133"
|
|
||||||
dependencies = [
|
|
||||||
"elliptic-curve",
|
|
||||||
"subtle",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "p384"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3aee0d9bdeedaea6cdd47f9281a9f8e1037d3037088b70e2af13c64ce65608ec"
|
|
||||||
dependencies = [
|
|
||||||
"elliptic-curve",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "p521"
|
|
||||||
version = "0.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "be25ade38ee14ce95ca4cc94ae139eef99c819419e05296f62d5ef09f67c668b"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "sha2"
|
|
||||||
version = "0.8.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "27044adfd2e1f077f649f59deb9490d3941d674002f7d062870a60ebe9bd47a0"
|
|
||||||
dependencies = [
|
|
||||||
"block-buffer",
|
|
||||||
"digest",
|
|
||||||
"fake-simd",
|
|
||||||
"opaque-debug",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "signature"
|
|
||||||
version = "1.0.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "685e1c5b65c6cc6fd0eb9ba63c6cfb8431f7f9c7e078c626f23f50e13fa378d7"
|
|
||||||
dependencies = [
|
|
||||||
"digest",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "subtle"
|
|
||||||
version = "2.2.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7c65d530b10ccaeac294f349038a597e435b18fb456aadd0840a623f83b9e941"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "typenum"
|
|
||||||
version = "1.12.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wasi"
|
|
||||||
version = "0.9.0+wasi-snapshot-preview1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "zeroize"
|
|
||||||
version = "1.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3cbac2ed2ba24cc90f5e06485ac8c7c1e5449fe8911aef4d8877218af021a5b8"
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "crypto"
|
|
||||||
version = "0.1.0"
|
|
||||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
|
||||||
edition = "2018"
|
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
ecdsa = "0.5.0"
|
|
||||||
ed25519 = "1.0.1"
|
|
||||||
digest = "0.8.1"
|
|
||||||
elliptic-curve = "0.3.0"
|
|
||||||
k256 = "0.2.0"
|
|
||||||
p256 = "0.2.0"
|
|
||||||
p384 = "0.1.0"
|
|
||||||
p521 = "0.0.0"
|
|
||||||
sha2 = "0.8.1"
|
|
||||||
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
use sha2::{Sha256, Sha512, Digest};
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
println!("{}", to_hex(&sha256(b"hello world")));
|
|
||||||
println!("{}", to_hex(&sha512(b"hello world")));
|
|
||||||
}
|
|
||||||
|
|
||||||
fn sha256(data: &[u8]) -> Vec<u8> {
|
|
||||||
let mut hasher = Sha256::new();
|
|
||||||
hasher.input(data);
|
|
||||||
let result = hasher.result();
|
|
||||||
result[..].to_vec()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn sha512(data: &[u8]) -> Vec<u8> {
|
|
||||||
let mut hasher = Sha512::new();
|
|
||||||
hasher.input(data);
|
|
||||||
let result = hasher.result();
|
|
||||||
result[..].to_vec()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn to_hex(bs: &[u8]) -> String {
|
|
||||||
bs.iter().map(|u| {
|
|
||||||
let x = format!("{:x}", u);
|
|
||||||
if x.len() == 1 {
|
|
||||||
"0".to_owned() + &x
|
|
||||||
} else {
|
|
||||||
x
|
|
||||||
}
|
|
||||||
}).collect()
|
|
||||||
}
|
|
||||||
246
pwhash/Cargo.lock
generated
246
pwhash/Cargo.lock
generated
@@ -1,246 +0,0 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
|
||||||
# It is not intended for manual editing.
|
|
||||||
[[package]]
|
|
||||||
name = "block-buffer"
|
|
||||||
version = "0.9.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4"
|
|
||||||
dependencies = [
|
|
||||||
"generic-array",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "block-cipher"
|
|
||||||
version = "0.7.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "fa136449e765dc7faa244561ccae839c394048667929af599b5d931ebe7b7f10"
|
|
||||||
dependencies = [
|
|
||||||
"generic-array",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "blowfish"
|
|
||||||
version = "0.5.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "91d01392750dd899a2528948d6b856afe2df508d627fc7c339868c0bd0141b4b"
|
|
||||||
dependencies = [
|
|
||||||
"block-cipher",
|
|
||||||
"byteorder",
|
|
||||||
"opaque-debug 0.2.3",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "byteorder"
|
|
||||||
version = "1.3.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cfg-if"
|
|
||||||
version = "0.1.10"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cpuid-bool"
|
|
||||||
version = "0.1.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "crypto-mac"
|
|
||||||
version = "0.8.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab"
|
|
||||||
dependencies = [
|
|
||||||
"generic-array",
|
|
||||||
"subtle",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "digest"
|
|
||||||
version = "0.9.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066"
|
|
||||||
dependencies = [
|
|
||||||
"generic-array",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "generic-array"
|
|
||||||
version = "0.14.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817"
|
|
||||||
dependencies = [
|
|
||||||
"typenum",
|
|
||||||
"version_check",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "getrandom"
|
|
||||||
version = "0.1.15"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if",
|
|
||||||
"libc",
|
|
||||||
"wasi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "hmac"
|
|
||||||
version = "0.8.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840"
|
|
||||||
dependencies = [
|
|
||||||
"crypto-mac",
|
|
||||||
"digest",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "libc"
|
|
||||||
version = "0.2.79"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2448f6066e80e3bfc792e9c98bf705b4b0fc6e8ef5b43e5889aff0eaa9c58743"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "md-5"
|
|
||||||
version = "0.9.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7b5a279bb9607f9f53c22d496eade00d138d1bdcccd07d74650387cf94942a15"
|
|
||||||
dependencies = [
|
|
||||||
"block-buffer",
|
|
||||||
"digest",
|
|
||||||
"opaque-debug 0.3.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "opaque-debug"
|
|
||||||
version = "0.2.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "opaque-debug"
|
|
||||||
version = "0.3.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ppv-lite86"
|
|
||||||
version = "0.2.9"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c36fa947111f5c62a733b652544dd0016a43ce89619538a8ef92724a6f501a20"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "pwhash"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"pwhash 0.3.1",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "pwhash"
|
|
||||||
version = "0.3.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1068eebd5d8aa4bbd6cbba05ff2647ad32f8ec86a3b73417b95522383c4bd18f"
|
|
||||||
dependencies = [
|
|
||||||
"blowfish",
|
|
||||||
"byteorder",
|
|
||||||
"hmac",
|
|
||||||
"md-5",
|
|
||||||
"rand",
|
|
||||||
"sha-1",
|
|
||||||
"sha2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rand"
|
|
||||||
version = "0.7.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
|
|
||||||
dependencies = [
|
|
||||||
"getrandom",
|
|
||||||
"libc",
|
|
||||||
"rand_chacha",
|
|
||||||
"rand_core",
|
|
||||||
"rand_hc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rand_chacha"
|
|
||||||
version = "0.2.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
|
|
||||||
dependencies = [
|
|
||||||
"ppv-lite86",
|
|
||||||
"rand_core",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rand_core"
|
|
||||||
version = "0.5.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
|
|
||||||
dependencies = [
|
|
||||||
"getrandom",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rand_hc"
|
|
||||||
version = "0.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
|
|
||||||
dependencies = [
|
|
||||||
"rand_core",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "sha-1"
|
|
||||||
version = "0.9.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "170a36ea86c864a3f16dd2687712dd6646f7019f301e57537c7f4dc9f5916770"
|
|
||||||
dependencies = [
|
|
||||||
"block-buffer",
|
|
||||||
"cfg-if",
|
|
||||||
"cpuid-bool",
|
|
||||||
"digest",
|
|
||||||
"opaque-debug 0.3.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "sha2"
|
|
||||||
version = "0.9.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2933378ddfeda7ea26f48c555bdad8bb446bf8a3d17832dc83e380d444cfb8c1"
|
|
||||||
dependencies = [
|
|
||||||
"block-buffer",
|
|
||||||
"cfg-if",
|
|
||||||
"cpuid-bool",
|
|
||||||
"digest",
|
|
||||||
"opaque-debug 0.3.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "subtle"
|
|
||||||
version = "2.3.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "343f3f510c2915908f155e94f17220b19ccfacf2a64a2a5d8004f2c3e311e7fd"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "typenum"
|
|
||||||
version = "1.12.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "version_check"
|
|
||||||
version = "0.9.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wasi"
|
|
||||||
version = "0.9.0+wasi-snapshot-preview1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "pwhash"
|
|
||||||
version = "0.1.0"
|
|
||||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
|
||||||
edition = "2018"
|
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
pwhash = "0.3"
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
use pwhash::bcrypt;
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
// Hash a password with default parameters.
|
|
||||||
let h_new = bcrypt::hash("password").unwrap();
|
|
||||||
|
|
||||||
// Verify a password against an existing hash.
|
|
||||||
let h = "$2y$05$bvIG6Nmid91Mu9RcmmWZfO\
|
|
||||||
5HJIMCT8riNW0hEp8f6/FuA2/mHZFpe";
|
|
||||||
assert!(bcrypt::verify("password", h));
|
|
||||||
}
|
|
||||||
1087
reqwest/Cargo.lock
generated
1087
reqwest/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -1,13 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "reqwest"
|
|
||||||
version = "0.1.0"
|
|
||||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
|
||||||
edition = "2018"
|
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
async-trait = "0.1.30"
|
|
||||||
tokio = { version = "0.2.6", features = ["full"] }
|
|
||||||
reqwest = "0.10.4"
|
|
||||||
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
use std::env;
|
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
#[tokio::main]
|
|
||||||
pub async fn main() {
|
|
||||||
let a = match env::args().nth(1) {
|
|
||||||
Some(a) => a, None => {
|
|
||||||
println!("[ERROR] No args");
|
|
||||||
return;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
let mut map: HashMap<_, Box<dyn Call>> = HashMap::new();
|
|
||||||
map.insert("1", Box::new(T001{}) );
|
|
||||||
map.insert("2", Box::new(T002{}) );
|
|
||||||
|
|
||||||
let c = match map.get(a.as_str()) {
|
|
||||||
Some(c) => c, None => {
|
|
||||||
println!("[ERROR] Cannot find {}", a);
|
|
||||||
return;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
match c.call().await {
|
|
||||||
Ok(_) => println!("[OK] Call fn ok: {}", a),
|
|
||||||
Err(err) => println!("[ERROR] Call fn error: {}, message: {}", a, err),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait::async_trait]
|
|
||||||
trait Call {
|
|
||||||
async fn call(&self) -> Result<(), Box<dyn std::error::Error>>;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct T001();
|
|
||||||
#[async_trait::async_trait]
|
|
||||||
impl Call for T001 {
|
|
||||||
async fn call(&self) -> Result<(), Box<dyn std::error::Error>> {
|
|
||||||
let ip = reqwest::get("https://hatter.ink/ip/ip.jsonp").await?.text().await?;
|
|
||||||
println!("{}", ip);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct T002();
|
|
||||||
#[async_trait::async_trait]
|
|
||||||
impl Call for T002 {
|
|
||||||
async fn call(&self) -> Result<(), Box<dyn std::error::Error>> {
|
|
||||||
// let resp = reqwest::get("https://hatter.ink/ip/ip.jsonp").await?;
|
|
||||||
// use std::io::Read;
|
|
||||||
|
|
||||||
// let mut buff = [0_u8; 1024];
|
|
||||||
|
|
||||||
// loop {
|
|
||||||
// match resp.read(buff) {
|
|
||||||
// Ok(_) => (),
|
|
||||||
// Err(_) => (),
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
println!("Hello World 2");
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
217
ring/Cargo.lock
generated
217
ring/Cargo.lock
generated
@@ -1,217 +0,0 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
|
||||||
# It is not intended for manual editing.
|
|
||||||
[[package]]
|
|
||||||
name = "bumpalo"
|
|
||||||
version = "3.3.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "5356f1d23ee24a1f785a56d1d1a5f0fd5b0f6a0c0fb2412ce11da71649ab78f6"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cc"
|
|
||||||
version = "1.0.53"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "404b1fe4f65288577753b17e3b36a04596ee784493ec249bf81c7f2d2acd751c"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cfg-if"
|
|
||||||
version = "0.1.10"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "hex"
|
|
||||||
version = "0.4.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "js-sys"
|
|
||||||
version = "0.3.39"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "fa5a448de267e7358beaf4a5d849518fe9a0c13fce7afd44b06e68550e5562a7"
|
|
||||||
dependencies = [
|
|
||||||
"wasm-bindgen",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "lazy_static"
|
|
||||||
version = "1.4.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "libc"
|
|
||||||
version = "0.2.70"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3baa92041a6fec78c687fa0cc2b3fae8884f743d672cf551bed1d6dac6988d0f"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "log"
|
|
||||||
version = "0.4.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "once_cell"
|
|
||||||
version = "1.4.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0b631f7e854af39a1739f401cf34a8a013dfe09eac4fa4dba91e9768bd28168d"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "proc-macro2"
|
|
||||||
version = "1.0.12"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8872cf6f48eee44265156c111456a700ab3483686b3f96df4cf5481c89157319"
|
|
||||||
dependencies = [
|
|
||||||
"unicode-xid",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "quote"
|
|
||||||
version = "1.0.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "42934bc9c8ab0d3b273a16d8551c8f0fcff46be73276ca083ec2414c15c4ba5e"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ring"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"hex",
|
|
||||||
"ring 0.16.13",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ring"
|
|
||||||
version = "0.16.13"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "703516ae74571f24b465b4a1431e81e2ad51336cb0ded733a55a1aa3eccac196"
|
|
||||||
dependencies = [
|
|
||||||
"cc",
|
|
||||||
"libc",
|
|
||||||
"once_cell",
|
|
||||||
"spin",
|
|
||||||
"untrusted",
|
|
||||||
"web-sys",
|
|
||||||
"winapi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "spin"
|
|
||||||
version = "0.5.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "syn"
|
|
||||||
version = "1.0.21"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4696caa4048ac7ce2bcd2e484b3cef88c1004e41b8e945a277e2c25dc0b72060"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"unicode-xid",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "unicode-xid"
|
|
||||||
version = "0.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "untrusted"
|
|
||||||
version = "0.7.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wasm-bindgen"
|
|
||||||
version = "0.2.62"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e3c7d40d09cdbf0f4895ae58cf57d92e1e57a9dd8ed2e8390514b54a47cc5551"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if",
|
|
||||||
"wasm-bindgen-macro",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wasm-bindgen-backend"
|
|
||||||
version = "0.2.62"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c3972e137ebf830900db522d6c8fd74d1900dcfc733462e9a12e942b00b4ac94"
|
|
||||||
dependencies = [
|
|
||||||
"bumpalo",
|
|
||||||
"lazy_static",
|
|
||||||
"log",
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
"wasm-bindgen-shared",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wasm-bindgen-macro"
|
|
||||||
version = "0.2.62"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2cd85aa2c579e8892442954685f0d801f9129de24fa2136b2c6a539c76b65776"
|
|
||||||
dependencies = [
|
|
||||||
"quote",
|
|
||||||
"wasm-bindgen-macro-support",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wasm-bindgen-macro-support"
|
|
||||||
version = "0.2.62"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8eb197bd3a47553334907ffd2f16507b4f4f01bbec3ac921a7719e0decdfe72a"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
"wasm-bindgen-backend",
|
|
||||||
"wasm-bindgen-shared",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wasm-bindgen-shared"
|
|
||||||
version = "0.2.62"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a91c2916119c17a8e316507afaaa2dd94b47646048014bbdf6bef098c1bb58ad"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "web-sys"
|
|
||||||
version = "0.3.39"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8bc359e5dd3b46cb9687a051d50a2fdd228e4ba7cf6fcf861a5365c3d671a642"
|
|
||||||
dependencies = [
|
|
||||||
"js-sys",
|
|
||||||
"wasm-bindgen",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "winapi"
|
|
||||||
version = "0.3.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6"
|
|
||||||
dependencies = [
|
|
||||||
"winapi-i686-pc-windows-gnu",
|
|
||||||
"winapi-x86_64-pc-windows-gnu",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "winapi-i686-pc-windows-gnu"
|
|
||||||
version = "0.4.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "winapi-x86_64-pc-windows-gnu"
|
|
||||||
version = "0.4.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "ring"
|
|
||||||
version = "0.1.0"
|
|
||||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
|
||||||
edition = "2018"
|
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
ring = "0.16.13"
|
|
||||||
hex = "0.4.2"
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
use ring::{
|
|
||||||
signature::{ KeyPair, Ed25519KeyPair, UnparsedPublicKey, ED25519 },
|
|
||||||
hmac, rand, error::Unspecified,
|
|
||||||
digest,
|
|
||||||
};
|
|
||||||
|
|
||||||
const SEED_LEN: usize = 32;
|
|
||||||
|
|
||||||
fn main() -> Result<(), Unspecified> {
|
|
||||||
{
|
|
||||||
println!("{} HHmac {}", "-".repeat(10), "-".repeat(10));
|
|
||||||
let rng = rand::SystemRandom::new();
|
|
||||||
let key = hmac::Key::generate(hmac::HMAC_SHA256, &rng)?;
|
|
||||||
|
|
||||||
let msg = "hello, world";
|
|
||||||
let tag = hmac::sign(&key, msg.as_bytes());
|
|
||||||
|
|
||||||
println!("{:?}", tag);
|
|
||||||
hmac::verify(&key, msg.as_bytes(), tag.as_ref())?;
|
|
||||||
println!("Verify success");
|
|
||||||
}
|
|
||||||
{
|
|
||||||
println!("{} SHA256 {}", "-".repeat(10), "-".repeat(10));
|
|
||||||
let sha256 = digest::digest(&digest::SHA256, b"hello, world");
|
|
||||||
println!("{:?}", sha256);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
println!("{} EdDSA {}", "-".repeat(10), "-".repeat(10));
|
|
||||||
let rng = rand::SystemRandom::new();
|
|
||||||
let seed: [u8; SEED_LEN] = rand::generate(&rng)?.expose();
|
|
||||||
println!("seed: {}", hex::encode(&seed));
|
|
||||||
let key_pair = Ed25519KeyPair::from_seed_unchecked(&seed)?;
|
|
||||||
println!("private: {:?}", key_pair);
|
|
||||||
let sig = key_pair.sign(&"hello world".as_bytes());
|
|
||||||
println!("signature: {}", hex::encode(sig.as_ref()));
|
|
||||||
let public_key = key_pair.public_key().as_ref();
|
|
||||||
let verify_result = UnparsedPublicKey::new(&ED25519, &public_key).verify(&"hello world".as_bytes(), sig.as_ref());
|
|
||||||
println!("verify: {}", verify_result.is_ok());
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
1347
rweb/Cargo.lock
generated
1347
rweb/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -1,11 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "rweb"
|
|
||||||
version = "0.1.0"
|
|
||||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
|
||||||
edition = "2018"
|
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
tokio = "0.2"
|
|
||||||
rweb = "0.4.0"
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
use rweb::*;
|
|
||||||
|
|
||||||
#[get("/name")]
|
|
||||||
fn name() -> String {
|
|
||||||
"Tom\n".into()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[get("/name/{n}")]
|
|
||||||
fn name_n(n: String) -> String {
|
|
||||||
format!("Hello: {}\n", n)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[get("/json_list")]
|
|
||||||
fn get_json_list() -> Json<Vec<String>> {
|
|
||||||
vec![ "1".into(), "2".into(), "3".into() ].into()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[get("/")]
|
|
||||||
fn root() -> String {
|
|
||||||
"Root\n".into()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tokio::main]
|
|
||||||
async fn main() {
|
|
||||||
println!("Start listen on: 127.0.0.1:8080 ...");
|
|
||||||
serve(
|
|
||||||
root()
|
|
||||||
.or(name())
|
|
||||||
.or(name_n())
|
|
||||||
.or(get_json_list())
|
|
||||||
).run(([127, 0, 0, 1], 8080)).await;
|
|
||||||
}
|
|
||||||
204
secp256k1/Cargo.lock
generated
204
secp256k1/Cargo.lock
generated
@@ -1,204 +0,0 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
|
||||||
# It is not intended for manual editing.
|
|
||||||
[[package]]
|
|
||||||
name = "autocfg"
|
|
||||||
version = "0.1.7"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bitflags"
|
|
||||||
version = "1.2.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cc"
|
|
||||||
version = "1.0.41"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8dae9c4b8fedcae85592ba623c4fd08cfdab3e3b72d6df780c6ead964a69bfff"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cloudabi"
|
|
||||||
version = "0.0.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "fuchsia-cprng"
|
|
||||||
version = "0.1.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "libc"
|
|
||||||
version = "0.2.66"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rand"
|
|
||||||
version = "0.6.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca"
|
|
||||||
dependencies = [
|
|
||||||
"autocfg",
|
|
||||||
"libc",
|
|
||||||
"rand_chacha",
|
|
||||||
"rand_core 0.4.2",
|
|
||||||
"rand_hc",
|
|
||||||
"rand_isaac",
|
|
||||||
"rand_jitter",
|
|
||||||
"rand_os",
|
|
||||||
"rand_pcg",
|
|
||||||
"rand_xorshift",
|
|
||||||
"winapi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rand_chacha"
|
|
||||||
version = "0.1.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef"
|
|
||||||
dependencies = [
|
|
||||||
"autocfg",
|
|
||||||
"rand_core 0.3.1",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rand_core"
|
|
||||||
version = "0.3.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
|
|
||||||
dependencies = [
|
|
||||||
"rand_core 0.4.2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rand_core"
|
|
||||||
version = "0.4.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rand_hc"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4"
|
|
||||||
dependencies = [
|
|
||||||
"rand_core 0.3.1",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rand_isaac"
|
|
||||||
version = "0.1.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08"
|
|
||||||
dependencies = [
|
|
||||||
"rand_core 0.3.1",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rand_jitter"
|
|
||||||
version = "0.1.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
"rand_core 0.4.2",
|
|
||||||
"winapi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rand_os"
|
|
||||||
version = "0.1.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071"
|
|
||||||
dependencies = [
|
|
||||||
"cloudabi",
|
|
||||||
"fuchsia-cprng",
|
|
||||||
"libc",
|
|
||||||
"rand_core 0.4.2",
|
|
||||||
"rdrand",
|
|
||||||
"winapi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rand_pcg"
|
|
||||||
version = "0.1.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44"
|
|
||||||
dependencies = [
|
|
||||||
"autocfg",
|
|
||||||
"rand_core 0.4.2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rand_xorshift"
|
|
||||||
version = "0.1.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c"
|
|
||||||
dependencies = [
|
|
||||||
"rand_core 0.3.1",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rdrand"
|
|
||||||
version = "0.4.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
|
|
||||||
dependencies = [
|
|
||||||
"rand_core 0.3.1",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "secp256k1"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"rand",
|
|
||||||
"secp256k1 0.17.2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "secp256k1"
|
|
||||||
version = "0.17.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2932dc07acd2066ff2e3921a4419606b220ba6cd03a9935123856cc534877056"
|
|
||||||
dependencies = [
|
|
||||||
"rand",
|
|
||||||
"secp256k1-sys",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "secp256k1-sys"
|
|
||||||
version = "0.1.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7ab2c26f0d3552a0f12e639ae8a64afc2e3db9c52fe32f5fc6c289d38519f220"
|
|
||||||
dependencies = [
|
|
||||||
"cc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "winapi"
|
|
||||||
version = "0.3.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6"
|
|
||||||
dependencies = [
|
|
||||||
"winapi-i686-pc-windows-gnu",
|
|
||||||
"winapi-x86_64-pc-windows-gnu",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "winapi-i686-pc-windows-gnu"
|
|
||||||
version = "0.4.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "winapi-x86_64-pc-windows-gnu"
|
|
||||||
version = "0.4.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "secp256k1"
|
|
||||||
version = "0.1.0"
|
|
||||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
|
||||||
edition = "2018"
|
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
secp256k1 = { version = "0.17.2", features = ["rand"] }
|
|
||||||
rand = "0.6"
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
use rand::rngs::OsRng;
|
|
||||||
use secp256k1::{Secp256k1, Message};
|
|
||||||
|
|
||||||
// https://docs.rs/secp256k1/0.17.2/secp256k1/
|
|
||||||
fn main() {
|
|
||||||
let secp = Secp256k1::new();
|
|
||||||
let mut rng = OsRng::new().expect("OsRng");
|
|
||||||
let (secret_key, public_key) = secp.generate_keypair(&mut rng);
|
|
||||||
let message = Message::from_slice(&[0xab; 32]).expect("32 bytes");
|
|
||||||
|
|
||||||
let sig = secp.sign(&message, &secret_key);
|
|
||||||
println!("{}", secret_key);
|
|
||||||
println!("{:?}", secret_key);
|
|
||||||
println!("{}", public_key);
|
|
||||||
println!("{:?}", public_key);
|
|
||||||
println!("{}", sig);
|
|
||||||
assert!(secp.verify(&message, &sig, &public_key).is_ok());
|
|
||||||
}
|
|
||||||
157
totp/Cargo.lock
generated
157
totp/Cargo.lock
generated
@@ -1,157 +0,0 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
|
||||||
# It is not intended for manual editing.
|
|
||||||
[[package]]
|
|
||||||
name = "base32"
|
|
||||||
version = "0.4.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "byteorder"
|
|
||||||
version = "1.3.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "fuchsia-cprng"
|
|
||||||
version = "0.1.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "gcc"
|
|
||||||
version = "0.3.55"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "libc"
|
|
||||||
version = "0.2.60"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "otpauth"
|
|
||||||
version = "0.2.7"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"base32 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rand"
|
|
||||||
version = "0.3.23"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rand"
|
|
||||||
version = "0.4.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rand_core"
|
|
||||||
version = "0.3.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rand_core"
|
|
||||||
version = "0.4.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rdrand"
|
|
||||||
version = "0.4.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "redox_syscall"
|
|
||||||
version = "0.1.56"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rust-crypto"
|
|
||||||
version = "0.2.36"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustc-serialize"
|
|
||||||
version = "0.3.24"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "time"
|
|
||||||
version = "0.1.42"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "totp"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"otpauth 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "winapi"
|
|
||||||
version = "0.3.7"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "winapi-i686-pc-windows-gnu"
|
|
||||||
version = "0.4.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "winapi-x86_64-pc-windows-gnu"
|
|
||||||
version = "0.4.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[metadata]
|
|
||||||
"checksum base32 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "23ce669cd6c8588f79e15cf450314f9638f967fc5770ff1c7c1deb0925ea7cfa"
|
|
||||||
"checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5"
|
|
||||||
"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
|
|
||||||
"checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2"
|
|
||||||
"checksum libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "d44e80633f007889c7eff624b709ab43c92d708caad982295768a7b13ca3b5eb"
|
|
||||||
"checksum otpauth 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "d298ed10078fef253425b62403a37bce0b2b0fa81ab018785f6a9d22dbaf64ae"
|
|
||||||
"checksum rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)" = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c"
|
|
||||||
"checksum rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293"
|
|
||||||
"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
|
|
||||||
"checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0"
|
|
||||||
"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
|
|
||||||
"checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84"
|
|
||||||
"checksum rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)" = "f76d05d3993fd5f4af9434e8e436db163a12a9d40e1a58a726f27a01dfd12a2a"
|
|
||||||
"checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda"
|
|
||||||
"checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f"
|
|
||||||
"checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770"
|
|
||||||
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
|
||||||
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "totp"
|
|
||||||
version = "0.1.0"
|
|
||||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
|
||||||
edition = "2018"
|
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
time = "0.1.42"
|
|
||||||
otpauth = "0.2.7"
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
extern crate otpauth;
|
|
||||||
extern crate time;
|
|
||||||
|
|
||||||
use otpauth::TOTP;
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let auth = TOTP::new("python");
|
|
||||||
let timestamp1 = time::now().to_timespec().sec as usize;
|
|
||||||
let code = auth.generate(30, timestamp1);
|
|
||||||
let timestamp2 = time::now().to_timespec().sec as usize;
|
|
||||||
println!("code: {}", code);
|
|
||||||
assert_eq!(true, auth.verify(code, 30, timestamp2));
|
|
||||||
}
|
|
||||||
6
wasi/Cargo.lock
generated
6
wasi/Cargo.lock
generated
@@ -1,6 +0,0 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
|
||||||
# It is not intended for manual editing.
|
|
||||||
[[package]]
|
|
||||||
name = "wasi"
|
|
||||||
version = "0.1.0"
|
|
||||||
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "wasi"
|
|
||||||
version = "0.1.0"
|
|
||||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
|
||||||
edition = "2018"
|
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
|
|
||||||
Prepare:
|
|
||||||
```shell
|
|
||||||
rustup target add wasm32-wasi
|
|
||||||
```
|
|
||||||
|
|
||||||
Compile:
|
|
||||||
```shell
|
|
||||||
cargo build --target=wasm32-wasi
|
|
||||||
```
|
|
||||||
|
|
||||||
```shell
|
|
||||||
$ ls target/
|
|
||||||
debug wasm32-wasi
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
运行时(Runtime)
|
|
||||||
> 运行这个文件,需要一个运行时(Runtime)。你也可以把这个理解成一个“容器”,“虚拟机”什么的,都行。但是准确的叫法是:运行时。
|
|
||||||
> 目前常见的运行时有 wasmtime,wasmer 等。
|
|
||||||
> 我们这次用 wasmtime 来运行吧。
|
|
||||||
|
|
||||||
`curl https://wasmtime.dev/install.sh -sSf | bash`
|
|
||||||
|
|
||||||
or download from:
|
|
||||||
|
|
||||||
https://github.com/bytecodealliance/wasmtime/releases
|
|
||||||
|
|
||||||
|
|
||||||
Run:
|
|
||||||
```
|
|
||||||
$ wasmtime --dir=. target/wasm32-wasi/debug/wasi.wasm
|
|
||||||
Hello, world!
|
|
||||||
```
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
Reference:
|
|
||||||
|
|
||||||
https://mp.weixin.qq.com/s/VYkUvD1NpRdx_qoIdCCq8w - _【Rust每周一知】Rust, wasm, wasi 试玩儿_
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
cargo build --target=wasm32-wasi
|
|
||||||
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
wasmtime --dir=. target/wasm32-wasi/debug/wasi.wasm
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
use std::fs::File;
|
|
||||||
use std::io::prelude::*;
|
|
||||||
|
|
||||||
fn main() -> std::io::Result<()> {
|
|
||||||
let mut file = File::create("foo.txt")?;
|
|
||||||
file.write_all(b"Hello, world!\n")?;
|
|
||||||
println!("Hello, world!");
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
126
wasm/Cargo.lock
generated
126
wasm/Cargo.lock
generated
@@ -1,126 +0,0 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
|
||||||
# It is not intended for manual editing.
|
|
||||||
[[package]]
|
|
||||||
name = "bumpalo"
|
|
||||||
version = "2.6.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cfg-if"
|
|
||||||
version = "0.1.9"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "hello-wasm"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"wasm-bindgen 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "lazy_static"
|
|
||||||
version = "1.4.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "log"
|
|
||||||
version = "0.4.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "proc-macro2"
|
|
||||||
version = "1.0.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "quote"
|
|
||||||
version = "1.0.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "syn"
|
|
||||||
version = "1.0.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "unicode-xid"
|
|
||||||
version = "0.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wasm-bindgen"
|
|
||||||
version = "0.2.50"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"wasm-bindgen-macro 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wasm-bindgen-backend"
|
|
||||||
version = "0.2.50"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"bumpalo 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"proc-macro2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"wasm-bindgen-shared 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wasm-bindgen-macro"
|
|
||||||
version = "0.2.50"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"wasm-bindgen-macro-support 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wasm-bindgen-macro-support"
|
|
||||||
version = "0.2.50"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"wasm-bindgen-backend 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"wasm-bindgen-shared 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wasm-bindgen-shared"
|
|
||||||
version = "0.2.50"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[metadata]
|
|
||||||
"checksum bumpalo 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ad807f2fc2bf185eeb98ff3a901bd46dc5ad58163d0fa4577ba0d25674d71708"
|
|
||||||
"checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33"
|
|
||||||
"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
|
||||||
"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
|
|
||||||
"checksum proc-macro2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4c5c2380ae88876faae57698be9e9775e3544decad214599c3a6266cca6ac802"
|
|
||||||
"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe"
|
|
||||||
"checksum syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "66850e97125af79138385e9b88339cbcd037e3f28ceab8c5ad98e64f0f1f80bf"
|
|
||||||
"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
|
|
||||||
"checksum wasm-bindgen 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "dcddca308b16cd93c2b67b126c688e5467e4ef2e28200dc7dfe4ae284f2faefc"
|
|
||||||
"checksum wasm-bindgen-backend 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "f805d9328b5fc7e5c6399960fd1889271b9b58ae17bdb2417472156cc9fafdd0"
|
|
||||||
"checksum wasm-bindgen-macro 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "3ff88201a482abfc63921621f6cb18eb1efd74f136b05e5841e7f8ca434539e9"
|
|
||||||
"checksum wasm-bindgen-macro-support 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "6a433d89ecdb9f77d46fcf00c8cf9f3467b7de9954d8710c175f61e2e245bb0e"
|
|
||||||
"checksum wasm-bindgen-shared 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "d41fc1bc3570cdf8d108c15e014045fd45a95bb5eb36605f96a90461fc34027d"
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "hello-wasm"
|
|
||||||
version = "0.1.0"
|
|
||||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
|
||||||
edition = "2018"
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
crate-type = ["cdylib"]
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
wasm-bindgen = "0.2"
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
|
|
||||||
from: https://developer.mozilla.org/en-US/docs/WebAssembly/Rust_to_wasm
|
|
||||||
|
|
||||||
build:
|
|
||||||
```
|
|
||||||
wasm-pack build
|
|
||||||
|
|
||||||
|
|
||||||
cd site/
|
|
||||||
npm install
|
|
||||||
npm run serve
|
|
||||||
```
|
|
||||||
|
|
||||||
Access: http://localhost:8080/
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>hello-wasm example</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<script src="./index.js"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
const js = import("./node_modules/hello-wasm/hello_wasm.js");
|
|
||||||
js.then(js => {
|
|
||||||
js.greet("WebAssembly");
|
|
||||||
});
|
|
||||||
5521
wasm/site/package-lock.json
generated
5521
wasm/site/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,13 +0,0 @@
|
|||||||
{
|
|
||||||
"scripts": {
|
|
||||||
"serve": "webpack-dev-server"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"hello-wasm": "../pkg"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"webpack": "^4.25.1",
|
|
||||||
"webpack-cli": "^3.1.2",
|
|
||||||
"webpack-dev-server": "^3.1.10"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
const path = require('path');
|
|
||||||
module.exports = {
|
|
||||||
entry: "./index.js",
|
|
||||||
output: {
|
|
||||||
path: path.resolve(__dirname, "dist"),
|
|
||||||
filename: "index.js",
|
|
||||||
},
|
|
||||||
mode: "development"
|
|
||||||
};
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
extern crate wasm_bindgen;
|
|
||||||
|
|
||||||
use wasm_bindgen::prelude::*;
|
|
||||||
|
|
||||||
#[wasm_bindgen]
|
|
||||||
extern {
|
|
||||||
pub fn alert(s: &str);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[wasm_bindgen]
|
|
||||||
pub fn greet(name: &str) {
|
|
||||||
alert(&format!("Hello, {}!", name));
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user