ABAP 中文件的 MD5 哈希值 [英] MD5 hash of a file in ABAP

查看:34
本文介绍了ABAP 中文件的 MD5 哈希值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 ABAP 中生成一个文本文件的 MD5 哈希值.我还没有找到任何标准解决方案来为一个非常大的文件生成它.函数模块CALCULATE_HASH_FOR_CHAR 不符合我的要求,因为它需要一个字符串作为输入参数.虽然它适用于较小的文件,但对于例如 4 GB 的文件,无法构造这么大的字符串.

I want to generate a MD5 hash of a text file in ABAP. I have not found any standard solution for generating it for a very big file. Function module CALCULATE_HASH_FOR_CHAR does not meet my requirements because it takes a string as an input parameter. Although it works for smaller files, in case of a for example 4 GB file one cannot construct such a big string.

有谁知道是否有一个标准的代码来做这件事(我的谷歌努力没有给我带来任何东西)或者也许有人在 ABAP 中有一个 MD5 算法来计算文件的哈希?

Does anybody know whether there is a standard piece of coding for doing that (my google efforts did not bring me anything) or maybe someone has an MD5 algorithm in ABAP that calculates the hash of a file?

推荐答案

看起来这个算法在 ABAP 中是不可能实现的,因为该语言不允许在计算.这也应该回答了为什么到目前为止还没有在 SAP 系统中实施的问题.无论哪种方式看起来都没有其他方法可以调用外部工具,遗憾的是,它几乎与平台无关.

It looks like the implementation of this algorithm is impossible in ABAP because of the fact that the language does not allow arithmetic overflows during the calculations. This should also answer the question why it has not been implemented so far in SAP system. Either way looks that there is no other way as to call an external tool which of course is, regrettably, hardly platform independent.

好的!因此,在 René 的大力帮助和 Java 中的快速 MD5 实现 的代码下,我创建了在ABAP中实现MD5算法.此实现允许使用更多字节更新计算出的哈希值,当然这些字节可能来自不同的来源.

Ok! So with a great help of René and the code of Fast MD5 Implementation in Java I created the implementation of MD5 algorithm in ABAP . This implementation allows to update the calculated hash with more bytes, which of course might be coming from different sources.

目前还没有任何方法可以获取文件,但无论如何大部分工作已经完成.

There is no method which takes a file so far but anyways most of the work has been done.

代码中包含了一些简单的 ABAP 单元测试,其中还记录了如何使用它.

Some simple ABAP Unit tests are included in the code, which also document how to use it.

这篇关于ABAP 中文件的 MD5 哈希值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆