uwsgi: option is ambiguous: http
利用qq邮箱作为个人邮件服务器发送邮件

用最简单方法解决api接口安全问题,几乎无法破解

妙音 posted @ 2019年1月01日 11:45 in python with tags web python , 2868 阅读
 

 场景描述

 
项目需要为第三方提供api服务接口。接口涉及到核心功能,如何保证接口安全。防止伪造身份、篡改数据?
 

思路

 
保障数据安全最好的方法,当然是加密了。无法解析内容,自然无法伪造,篡改。

可是使用https证书需要收费的。有其它方法么?

有的。

消息哈希认证(hmac)。
 
 

 算法描述

 
*  访问者
 
1. 当访问接口时, 将参数按key值排序,组成key1=value1&key2=value2&....&secret_key=...
2. 然后对上面结果做md5,生成签名sign
3. 将sign放到加入请求的参数
 
* 被访问者
 
密钥是被访问者提供了,它也有访问者的secret_key.
1.根据app_id查到secret_key
2.处理请求参数,按规则组成key1=value1&key2=value2....&secret_key=...
3.对上一步结果做md5,生成sign。比较两个sign,相等则身份验证通过
 

效果

 
1. 密钥只存在双方机器上,不可能被截取
2. 签名无法伪造,同样身份无法伪造、消息无法被篡改
 
使用了hmac认证,接口被破解基本是不可能的
 

python实现

 
import md5

app_id=123
secret_key="xxxxxxxx"

request_param = dict(
    key1="value1",
    key2="value2",
    key3="value3"
)

def sign():
    params = ["%s=%s" % (key, value) for key, value in sorted(request_param.items(), key=lambda item: item[0])]
    params.append("secret_key=%s" % secret_key)
    str_param = "&".join(params)
    print str_param
    md = md5.md5()
    md.update(str_param)
    return md.hexdigest()

if __name__ == '__main__':
    print(sign())
 
 
来源
 

 

Avatar_small
Zeeworld 说:
2019年9月02日 02:31

I am unable to read articles online very often, but I’m glad I did today. This is very well written and your points are well-expressed. Please, don’t ever stop writing.

Avatar_small
MHR Writer 说:
2019年9月30日 13:22

It's really hard to complete the chest.MHR Writer

Avatar_small
Buy website Traffic 说:
2019年10月10日 12:38

Without fail, your writing style is top professional; even your website also looks amazing thank you for posting.

Avatar_small
remembrance sunday q 说:
2019年10月11日 20:21

A great content material as well as great layout. Your website deserves all of the positive feedback it’s been getting. I will be back soon for further quality contents.

Avatar_small
talk to random peopl 说:
2019年10月23日 22:16

This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free.

Avatar_small
http://vigile.quebec 说:
2019年10月25日 09:37

Excellent website! I adore how it is easy on my eyes it is. I am questioning how I might be notified whenever a new post has been made. Looking for more new updates. Have a great day!

Avatar_small
ménage à domicile pa 说:
2019年10月25日 18:03

You know your projects stand out of the herd. There is something special about them. It seems to me all of them are really brilliant!

Avatar_small
f88tw 说:
2019年10月27日 11:05

敬启者:个人小网站希望大家多多支持 感谢您对我们热心的支持 f88tw┃华歌尔┃I appreciate your kind assistance. http://mypaper.pchome.com.tw/f88tw/P1 http://mypaper.pchome.com.tw/f88tw/post/1379131888 http://mypaper.pchome.com.tw/f88tw/post/1370781143|墓园|禁忌|捡骨师|新竹|台北|桃园|苗栗|头份|

Avatar_small
talk to random peopl 说:
2019年10月29日 09:22

 

I wanted to thank you for this excellent read!! I definitely loved every little bit of it. I have you bookmarked your site to check out the new stuff you post.  talk to random people online

 

 

Avatar_small
avast premier crack 说:
2019年10月29日 14:01

Here at this site really the fastidious material collection so that everybody can enjoy a lot.

Avatar_small
Jacket Master 说:
2019年10月30日 18:17

Amazing knowledge and I like to share this kind of information with my friends and hope they like it they why I do

Avatar_small
Prined boxes 说:
2019年11月01日 18:54

This article gives the light in which we can observe the reality. This is very nice one and gives indepth information. Thanks for this nice article.

Avatar_small
http://cuisipat.com 说:
2019年11月02日 10:10

Superior post, keep up with this exceptional work. It's nice to know that this topic is being also covered on this web site so cheers for taking the time to discuss this! Thanks again and again!

Avatar_small
assignment help onli 说:
2019年11月04日 14:41

Thanks a lot to think about us and write such a beautiful article, always give your best and be successful in your future, I have a good process to make assignment by assignment help online through our expert.

Avatar_small
http://blackgromstud 说:
2019年11月05日 18:58

This article gives the light in which we can observe the reality. This is very nice one and gives indepth information. Thanks for this nice article.

Avatar_small
seo 说:
2019年11月06日 22:48

 

You have performed a great job on this article. It’s very precise and highly qualitative. You have even managed to make it readable and easy to read. You have some real writing talent. Thank you so much. http://test.otowroclaw.com/news.php?id=74487&tytul=zbliza-sie-polcon-2012

Avatar_small
morning desert safar 说:
2019年11月09日 09:46

Very informative post! There is a lot of information here that can help any business get started with a successful social networking campaign.

Avatar_small
https://www.otodolny 说:
2019年11月12日 22:15

This article gives the light in which we can observe the reality. This is very nice one and gives indepth information. Thanks for this nice article.

Avatar_small
Assignment Help 说:
2019年11月13日 14:28

Found your post interesting to read. Sometimes, It become troublesome to make time for writing assignments. We understand such situation. We provide you assignment help service for students and complete it for you before the deadline.

Avatar_small
All Assignment Help 说:
2019年11月13日 14:30

Found your post interesting to read. Sometimes, It become troublesome to make time for writing assignments. We understand such situation. We provide you assignment help service for students and complete it for you before the deadline.

Avatar_small
https://www.wykop.pl 说:
2019年11月21日 11:05

This article gives the light in which we can observe the reality. This is very nice one and gives indepth information. Thanks for this nice article.

Avatar_small
tomtom go navigation 说:
2019年11月23日 11:06

This article gives the light in which we can observe the reality. This is very nice one and gives indepth information. Thanks for this nice article.

Avatar_small
http://wizaz.pl/foru 说:
2019年11月24日 10:55

Very good points you wrote here..Great stuff...I think you've made some truly interesting points.Keep up the good work.

Avatar_small
click over here 说:
2019年11月24日 17:51

A great website with interesting and unique material what else would you need.

Avatar_small
seoagency 说:
2019年11月25日 20:44

ellent website! I adore how it is easy on my eyes it is. I am questioning how I might be notified whenever a new post has been made. Looking for more new updates. Have a great day! http://www.chezbeckyetliz.com/2006/06/blogs-de-cuisine-france-sites-utiles-en-grande-bretagne.html

Avatar_small
voyance immediate 说:
2019年11月26日 19:58

This is just the information I am finding everywhere. Thanks for your blog, I just subscribe your blog. This is a nice blog..

Avatar_small
eva sâm tố nữ 说:
2019年11月27日 11:12

This article gives the light in which we can observe the reality. This is very nice one and gives indepth information. Thanks for this nice article.

Avatar_small
https://www.cancerco 说:
2019年11月27日 18:59

Thank you for very usefull information..

Avatar_small
Assignment Help 说:
2019年11月29日 16:54

We offer the best online assignment help and academic writing service in AUS, UK & USA. Hire native experts now & get FLAT 20% OFF on your first order.

Avatar_small
Dissertation Editing 说:
2019年11月29日 18:17

Need Dissertation Help UK? GotoDissertationHelp offers Online Dissertation Help Services by top Phd Experts. Get Instant dissertation help now !

https://www.gotodissertationhelp.co.uk/marketing-dissertation-help/
https://www.gotodissertationhelp.co.uk/dissertation-writing-help/

https://www.gotodissertationhelp.co.uk/ae/

Avatar_small
Assignment help 说:
2019年11月29日 19:16

We can help you whenever and where ever you want, We are giving services all over world and especially in Australia in following catagories: Assignment help

Avatar_small
catalytic oxidizer d 说:
2019年11月30日 10:14

I really like your take on the issue. I now have a clear idea on what this matter is all about..

Avatar_small
Before Orion 说:
2019年12月01日 10:40

I'm glad to see the great detail here!.

Avatar_small
http://www.fourwinds 说:
2019年12月01日 13:13

This is a good post. This post gives truly quality information. I’m definitely going to look into it. Really very useful tips are provided here. Thank you so much. Keep up the good works.

Avatar_small
recuperative thermal 说:
2019年12月03日 11:01

I really like your take on the issue. I now have a clear idea on what this matter is all about..

Avatar_small
정보이용료 현금화 说:
2019年12月05日 21:28

I was reading some of your content on this website and I conceive this internet site is really informative ! Keep on putting up.정보이용료 현금화

Avatar_small
seoagency 说:
2019年12月07日 15:19

 

I wanted to thank you for this great read!! I definitely enjoying every little bit of it I have you bookmarked to check out new stuff you post. Malwarebytes Full Keygen Download

Avatar_small
aileen 说:
2019年12月07日 20:14

I just couldn't leave your website before telling you that I truly enjoyed the top quality info you present to your visitors? Will be back again frequently to check up on new posts. Breaking News Today

Avatar_small
http://lizzyshealthy 说:
2019年12月08日 13:14

I was reading some of your content on this website and I conceive this internet site is really informative ! Keep on putting up

Avatar_small
seoagency 说:
2019年12月08日 15:20

I’ve been surfing online more than three hours today, yet I never found any interesting article like yours. It’s pretty worth enough for me. In my opinion, if all webmasters and bloggers made good content as you did, the web will be a lot more useful than ever before. Ummy Video Downloder Full Crack

Avatar_small
http://dir.whatuseek 说:
2019年12月08日 17:13

I love the way you write and share your niche! Very interesting and different! Keep it coming! [url=http://dir.whatuseek.com/Reference/Education/Special_Education/Inclusion]http://dir.whatuseek.com/Reference/Education/Special_Education/Inclusion[/url]

Avatar_small
aileen 说:
2019年12月09日 20:07

Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. If possible, as you gain expertise, would you mind updating your blog with extra information? It is extremely helpful for me. thermal underwear for men

Avatar_small
seoagency 说:
2019年12月09日 21:55

The article looks magnificent, but it would be beneficial if you can share more about the suchlike subjects in the future. Keep posting. Filmora 9.2.10 Crack

Avatar_small
seoagency 说:
2019年12月11日 15:41

I read that Post and got it fine and informative. Lumion 10 Pro Crack full Download 2020

Avatar_small
Zonnepanelen install 说:
2019年12月11日 17:24

This is a great high resolution screen which you have shared for the users. Making a website is not an easy task but managing a good website is really a hard work. As far as this website is concerned, I am very happy. [url=https://zonnepanelen-installateur.be/]Zonnepanelen installateur[/url]

Avatar_small
seoagency 说:
2019年12月14日 22:39

 

Nice to be visiting your blog again, it has been months for me. Well this article that i've been waited for so long. I need this article to complete my assignment in the college, and it has same topic with your article. Thanks, great share. Best Cleaning company in Abu Dhabi

Avatar_small
seoagency 说:
2019年12月15日 20:23

This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free. franchise business

Avatar_small
seoagency 说:
2019年12月16日 21:24

This blog is so nice to me. I will keep on coming here again and again. Visit my link as well.. adwords clicker bot

Avatar_small
seoagency 说:
2019年12月17日 19:18

When you use a genuine service, you will be able to provide instructions, share materials and choose the formatting style. Buy premium Authentic Documents

Avatar_small
https://oregontruffl 说:
2019年12月18日 00:10

Great job for publishing such a beneficial web site. Your web log isn’t only useful but it is additionally really creative too. There tend to be not many people who can certainly write not so simple posts that artistically. Continue the nice writing

Avatar_small
seoagency 说:
2019年12月18日 21:53

y awesome blog post. We are really grateful for your blog post. You will find a lot of approaches after visiting your post. Youtube seo

Avatar_small
aileen 说:
2019年12月23日 16:20

Thanks for a wonderful share. Your article has proved your hard work and experience you have got in this field. Brilliant .i love it reading. gtv news website

Avatar_small
aileen 说:
2019年12月23日 18:59

Thanks for this great post, i find it very interesting and very well thought out and put together. I look forward to reading your work in the future. Rent a car in Dubai

Avatar_small
f88tw┃华歌尔 说:
2019年12月28日 08:31

敬启者:个人小网站希望大家多多支持 感谢您对我们热心的支持 f88tw┃华歌尔┃I appreciate your kind assistance. f88tw|墓园|捡骨流程|捡骨费用|捡骨时间|禁忌|捡骨颜色|捡骨师|新竹|时间|台北|桃园|苗栗|头份|火化|晋塔|安葬|法事|捡骨|看日子|墓穴|墓园|坟墓

Avatar_small
Zee sayings 说:
2020年1月01日 17:27

Positive site, where did u think of the data on this posting? I'm satisfied I found it, however, I will be returning soon to <a href=" http://www.publictvmedia.net/"> Digital marketing agency in Dubai</a>

Avatar_small
Micheal 说:
2020年1月09日 18:16

<a href="https://gistgallery.com/">favorite music</a>

Avatar_small
Making an essay 说:
2020年1月09日 18:17

Such an informative set of information. The format or the layout of the write-up is very impressive and it provides the readers with an idea of how to portray a serious matter in such an interesting manner. I will want to thank the admin and let know that going through the article was worthy. I work as an academic consultant for a website which provides academic solutions to students. Therefore, I will share the link of this website with students asking me questions regarding the process of making an essay.

Avatar_small
seoagency 说:
2020年1月27日 16:27

Someone Sometimes with visits your blog regularly and recommended it in my experience to read as well. The way of writing is excellent and also the content is top-notch. Thanks for that insight you provide the readers! Unique SEO BackLinks

Avatar_small
JOHN 说:
2020年2月02日 22:19

ool stuff you have got and you keep update all of us. SEO Services OffPage

Avatar_small
JOHN 说:
2020年2月07日 18:16

ks for posting this info. I just want to let you know that I just check out your site and I find it very interesting and informative. I can't wait to read lots of your posts. carpet abu dhabi

Avatar_small
JOHN 说:
2020年2月08日 00:01

ood post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon. Big thanks for the useful info. http://abudhabicarpet.ae

Avatar_small
JOHN 说:
2020年2月09日 04:08

I really loved reading your blog. It was very well authored and easy to understand. Unlike other blogs I have read which are really not that good.Thanks alot! Top-notch services from website SEO Services

Avatar_small
Nursing Assignment W 说:
2020年2月10日 21:43

Students who seek <a href="https://researchpapers247.com/nursing-assignment-writing/"> Nursing Assignment Writing Services Online</a> from a writing company are guaranteed of getting good grades for their <a href="https://researchpapers247.com/nursing-assignment-writing/"> Nursing Assignment Writing Help</a> and <a href="https://researchpapers247.com/nursing-assignment-writing/"> Online Nursing Assignment Writing Services</a> that are free from grammatical errors.

Avatar_small
Nursing Research Pap 说:
2020年2月10日 21:44

Companies offering Nursing Research Paper Writing Services should help students perform well by delivering papers prior to deadline as early delivery of Custom Nursing Research Papers and Nursing Term Paper Writing Services is very important.
https://www.meldaresearch.com/nursing-research-papers/

Avatar_small
JOHN 说:
2020年2月10日 22:27

 

Thanks for the nice blog. It was very useful for me. I'm happy I found this blog. Thank you for sharing with us,I too always learn something new from your post. articles

Avatar_small
JOHN 说:
2020年2月14日 23:32

h for this information. I have to let you know I concur on several of the points you make here and others may require some further review, but I can see your viewpoint. Jet Charter

Avatar_small
seoagency 说:
2020年2月16日 21:47

Thanks for sharing us. best desert safari dubai


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter