# Abi.encode VS abi.encodePacked

**URL:** <https://forum.openzeppelin.com/t/abi-encode-vs-abi-encodepacked/2948>\
**Category:** Support\
**Created:** [May 26, 2020, 8:45am UTC](https://forum.openzeppelin.com/t/abi-encode-vs-abi-encodepacked/2948 "2020-05-26T08:45:19Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [May 27, 2020, 6:34am UTC](https://forum.openzeppelin.com/t/abi-encode-vs-abi-encodepacked/2948/2 "2020-05-27T06:34:06Z")

</div>

Hi @bb_terk,

See the Solidity documentation for [0.5 breaking changes](https://solidity.readthedocs.io/en/latest/050-breaking-changes.html) for the difference between `abi.encode` and `abi.encodePacked`

> The ABI encoder now properly pads byte arrays and strings from calldata (`msg.data` and external function parameters) when used in external function calls and in `abi.encode`. For unpadded encoding, use `abi.encodePacked`.

`abi.encodePacked` is a [non-standard packed mode](https://solidity.readthedocs.io/en/latest/abi-spec.html#non-standard-packed-mode)

> Through `abi.encodePacked()` , Solidity supports a non-standard packed mode where:
> 
> - types shorter than 32 bytes are neither zero padded nor sign extended and
> - dynamic types are encoded in-place and without the length.
> - array elements are padded, but still encoded in-place
> 
> Furthermore, structs as well as nested arrays are not supported.

I am not sure why the tutorial they give uses a mix of `abi.encode` and `abi.encodePacked` rather than just using `abi.encode`

* * *

You could look at OpenZeppelin Contracts [ECDSA](https://docs.openzeppelin.com/contracts/3.x/api/cryptography#ECDSA) to verify signed messages.

---

_[View the full topic](https://forum.openzeppelin.com/t/abi-encode-vs-abi-encodepacked/2948)._
