Skip to content

Instantly share code, notes, and snippets.

View xieyuschen's full-sized avatar
🫡
Love and Peace

Griffin xieyuschen

🫡
Love and Peace
View GitHub Profile
@xieyuschen
xieyuschen / encounter_cors.md
Last active December 28, 2020 13:32
Cannot make a request to certain api for CORS

Cross Origin Resource Share

之前遇到的问题

之前的跨域问题很意外,hmm,我对这个东西还没有什么概念。情况是这样的,首先我写了几个api,然后监听8080端口。使用nginx进行代理,将对80访问的内容和对432访问的内容全部转发到127.0.0.1:8080去。然后前端在发请求的时候就遇到了跨域的问题。 解决方案:在nginx里面加一个同意跨域的设置 Access-Control-Allow-Origin:*。即可解决。

简单的提几个问题出来:

  • 跨域请求被阻塞发生在什么时候? 是nginx完成的阻塞,还是程序本身的阻塞

回答 阻塞由浏览器来完成,即正常发送请求,后端正常给予响应,但响应结果被浏览器拦截

@xieyuschen
xieyuschen / Unknown_encryption.md
Created December 10, 2020 17:32
Unknown type of public key

How to specify which way the key pair specified?

Here I record how to generate a key-pair to encrypt and decrypt. So I'm sure it use rsa pkcs1v15 to encrypt,and I can do encrypt and decrypt directly as the post above.
But when it comes to a given public-private key pair,thing seems unnormal:

Problem I encoutered:

When I encountered key pair in thoes files(pay attention that this is base64 encoding):

  • public.pem:
-----BEGIN PUBLIC KEY-----
@xieyuschen
xieyuschen / Rsa_using.md
Last active December 10, 2020 09:05
Encrypt and decrypt by ras pkcs1 by key-pair in pem files

Encrypt and decrypt by ras pkcs1 by key-pair in pem files

Generate Key-Pair randomly

Thanks to blog here, I finally understood how rsa encrypt and decrypt.

Generate public-private key pair

//copy from https://gist.github.com/miguelmota/3ea9286bd1d3c2a985b67cac4ba2130a 
//call GenerateKeyPair() can generate public-private key pem file for you
func GenerateKeyPair(){