ABAP中文件的MD5散列 [英] MD5 hash of a file in ABAP

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

问题描述

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



有人知道是否有标准的编码为了做到这一点(我的谷歌努力没有给我带来任何东西),或者也许有人在ABAP中有一个MD5算法来计算文件的哈希值? 解决方案看起来这个算法的实现在 ABAP 中是不可能的,因为在计算过程中语言不允许算术溢出。这也应该回答为什么迄今尚未在SAP系统中实施的问题。无论哪种方式看起来没有其他的方式来调用一个外部工具,当然这是令人遗憾的,几乎不依赖于平台。编辑:好的!因此,通过René的大力帮助和 Java中的快速MD5实现,我创建了在ABAP中实现MD5算法。这个实现允许用更多的字节来更新计算出来的散列,这当然可能来自不同的来源。



目前还没有一种方法需要一个文件,但反正大多数已完成工作。



一些简单的ABAP单元测试包含在代码中,它也记录了如何使用它。


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.

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?

解决方案

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.

EDIT: 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.

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

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

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